If you want the path to the context node from the document root, there's this handy path() function which includes position values.
If that's not what you want I'm confused.
-- Graydon
On Tue, May 17, 2016, 10:14 Christoph Gaukel christoph.gaukel@gmx.de wrote:
Hi Rob,
maybe you think of something like the following function:
declare function local:getInfo( $anyelement as item() ){ if ($anyelement instance of element()) then string-join( for $e in $anyelement/ancestor-or-self::* return if (exists($e/@*)) then concat( name($e), string-join( for $attr in $e/@* return "[@" || $attr/name() || "=" || '''' || $attr/string() || '''' || "]", '' ) ) else if ($e/preceding-sibling::*[name(.) = name($e)]) then let $pos := count($e/preceding-sibling::*[name(.) = name($e)])
- 1 return name($e) || "[" || $pos || "]" else if ($e/following-sibling::*[name(.) = name($e)]) then name($e) || "[1]" else name($e), '/' ) else ()
};
Christoph
Am 17.05.2016 um 15:51 schrieb Rob Stapper:
Hi Chistian,
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.
Unfortunately it only returns a bunch of: 1.
[ 1] $element/ancestor-or-self::* ! ./fn:position()
Should this work?
Is there some other ;-) clever way to retrieve a path to a random element that is being processed?
TIA for your reply,
Rob Stapper