Re: [xsl] Determine position in node sequence based on criteria

Subject: Re: [xsl] Determine position in node sequence based on criteria
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 30 Jun 2010 15:19:15 +0100
> Agreed. It seems like it would be real handy to have position() take
> an argument:
>
>  position(../s[])
>
> and return the position of the matching items...

did my count preceding-sibling suggestion not fit?

> or have a different
> function where you could get the position in a for expression:
>
> for $i in ../s
>  if (...) then $i/position() else ()

In xquery you do

for $i at $pos in ../s return
 if (...) then $pos else ()

However thats exactly the same as:

for $i in ../s return
 if (...) then 1 + count($i/preceding-sibling::s) else ()


--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread