How to find the occurrence number of a given element within a given ancestor?

Subject: How to find the occurrence number of a given element within a given ancestor?
From: Geir Ove Gronmo <geirog@xxxxxxxx>
Date: Tue, 29 Apr 1997 20:56:56 +0100
Hello!

Does anyone have a function that returns the occurrence number of a given
element within a given ancestor?

I haven't found a function that could do this in the standard (yet :-), but
I've found these (and some others):

(child-number snl) returns the occurence of snl within its parent element. 

(element-number snl) returns the occurrence of snl within the document
element.

Please correct me if my interpretation is wrong. Anyhow, these functions
aren't appropriate in my case.

The function should have the following public interface and should return a
number:

(element-in-ancestor-number  snl       snl      )
                             ^         ^
                             element   ancestor


What I particularly want to do in this case is to retrive the occurence
number of the currently open figure element in the currently open chapter
element.

In this case it would look something like this:

(element-in-ancestor-number 
                 ((ancestor "figure" (current-node))) 
                 ((ancestor "chapter" (current-node))))

</Gr0ve>
------------------  Geir Ove Grønmo  ------------------
  Falch Infotek as, Stanseveien 21, 0902 Oslo, Norway
      Phone: +47 22 90 27 36 Fax: +47 22 90 25 99
 [grove@xxxxxxxx | http://www.falch.no/people/geirog]
-------------------------------------------------------

 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread