Hi Graydon, probably I misunderstand you, but isn't $node/count(preceding-sibling::*) + 1 what you need?
Kind regards, Hans-Jürgen

Am Donnerstag, 30. Juni 2022, 17:21:34 MESZ hat Graydon Saunders <graydonish@gmail.com> Folgendes geschrieben:


Hello --

I've got an element node that's part of a document.  I need its position among the element children of its parent.

$step/position() will (correctly!) always return 1, there's one thing in $step, of course it does.

replace($step/path(),'^.*\[(\p{Nd}+)\]$','$1') => xs:integer()

gets me the implicit position but is something of a horror.

for $e at $in in $step/../* where $e is $step return $in

works, too, but any notion of elegance and clarity have fled screaming into the night.

I keep thinking there must be a better way; anyone got any suggestions?

Thanks!
Graydon