Cheers from abroad ;) And thanks to Dirk (and everyone else) for all the replies on the mailing list,

Christian

Am 17.05.2016 18:40 schrieb "Rob Stapper" <r.stapper@lijbrandt.nl>:
Thanx all you guys,

Great  to see this much response.

fn:path() is exactly what I needed. I do feel a little awkward though that I missed this one.

Cheers,
Rob

-----Oorspronkelijk bericht-----
Van: Leonard Wörteler [mailto:leonard.woerteler@uni-konstanz.de]
Verzonden: dinsdag 17 mei 2016 16:34
Aan: Rob Stapper
CC: BaseX
Onderwerp: Re: [basex-talk] question

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