Stéphane Mottelet wrote:
Hi, I have the following problem
<stuff>
<e1>
...
</e1>
<e1>
<e2/>
</e1>
</stuff>
When I am in the context of node <e2/>
how can I compute the position of its
parent <e1/within <stuff(position=2 here) ?
position depends on the current node list and that can be different
depending on select expressions. For instance in your sample above if
you have
<xsl:template match="stuff">
<xsl:apply-templates/>
</xsl:template>
then the second 'e1' element has position 4 as there is white space
between the 'stuff' element and the 'e1' elements.
So it is not clear what you understand the position to be, if you want
to count the siblings of the same node type and name then use e.g.
<xsl:template match="e2">
<xsl:value-of select="count(.. | ../preceding-sibling::e1)"/>
</xsl:template>
xsl:number can also be helpful, depending on your needs.
--
Martin Honnen
http://JavaScript.FAQTs.com/