RE: position() of the parent

Subject: RE: position() of the parent
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Wed, 19 Jan 2000 18:10:29 -0700
> Worked great! But just for my curiosity, is there any way to 
> find the position() of the parent?

An interesting challenge. I really should test this before I post it...

<xsl:variable name="parent_position">
  <!-- establish the context: parent and its sibling elements -->
  <xsl:for-each select="../../*">
    <!-- when node being looked at is the parent -->
    <xsl:if test="generate-id() = generate-id(current()/parent::*)">
      <!-- use the context position of that node -->
      <xsl:value-of select="position()"/>

If this works, it will make $parent_position a result tree fragment
containing a text node that has the number you want. If you want it to be an
object of type number, you can later select number($parent_position).

 XSL-List info and archive:

Current Thread