Hi Rob,
Am 17.05.2016 um 15:51 schrieb Rob Stapper:
In order to get some path to the element that is being processed I hoped that the following statement [ 1] would return a sequence of positions of each node amongst its siblings.
[ 1] $element/ancestor-or-self::* ! ./fn:position()
Should this work?
no, that this does not work because the `fn:position()` function returns the position of the context item in the innermost path expression, which in your case is `./fn:position()`.
Is there some other ;-) clever way to retrieve a path to a random element that is being processed?
Graydon already mentioned the `fn:path($node)` function, which returns a valid XPath expression that uniquely identifies the given node. If you just want to get the position of each ancestor inside its parent, you can simply count all its preceding siblings and add one:
$element/ancestor-or-self::*/(count(preceding-sibling::*) + 1)
Hope that helps, Leo