[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: Re: [xsl] Determine position in node sequence based on criteria
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 30 Jun 2010 15:31:39 +0100

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 ()


It's the same in this case, but


(a) it relies on the "in" expression ../s returning a sequence of siblings, and

(b) the second solution is likely to be O(n^2) while the first is likely to be O(n).

Michael Kay
Saxonica


Current Thread
Keywords