On 26/08/2012 07:49, Ihe Onwuka wrote:
Assuming Xpath 2.0 take a look at the index-of function.
No, index-of() is no use because it compares nodes by value rather than
by identity.
The question is a bit confusing because you talk of a "node-set" which
is XPath 1.0 terminology; but a set of nodes by definition has no
particular order and therefore the nodes it contains have no particular
position. The code you showed finds the position of a node within the
sequence of nodes formed by sorting the nodes in the node-set into
document order.
If you are using XPath 2.0, and if what you mean is a node sequence
rather than a node set, then you can find the positions of a node within
the sequence (the same node might be at more than one position...) using
for $i in 1 to count($nodes)) return $i[$nodes[$i] is $node]
Michael Kay
Saxonica
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--