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
Am 30.06.2022 um 17:21 schrieb Graydon Saunders:
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?
I think functx has some node-index-of you could use or use e.g.
index-of($step/../*/generate-id(), generate-id($step))
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
… or I’d probably simply listen to Hans-Jürgen ;)
On Thu, Jun 30, 2022 at 5:32 PM Christian Grün christian.gruen@gmail.com wrote:
I’d probably do this:
count($step/preceding-sibling::*) + 1
basex-talk@mailman.uni-konstanz.de