[XSL-LIST Mailing List Archive Home]
RE: [xsl] Problem getting position of node
Subject: RE: [xsl] Problem getting position of node|
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 21 Mar 2006 09:12:50 -0000
By the "position" of the node I imagine you mean the number of preceding
sibling nodes (or elements?) plus one. You can get that using
count(preceding-sibling::node()) + 1
count(preceding-sibling::*) + 1
depending which you want.
You can also use <xsl:number/>.
The position() function gives you something quite different: its value is
unrelated to the position of a node in the tree, it depends only on the
position of the node within the sequence of nodes currently selected for
> Error in expression concat(., parent::node()/position()): Unexpected
> token [<function>] in path expression
XSLT 1.0 doesn't allow a function call on the rhs of "/". XSLT 2.0 does. But
parent::node()/position() will always return 1: a node has only one parent
and the position of that parent among all the parents is therefore always 1.