[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Determine position in node sequence based on crite

Subject: Re: Determine position in node sequence based on criteria
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 30 Jun 2010 15:28:32 +0100
Re:  Determine position in node sequence based on crite
Agreed. It seems like it would be real handy to have position() take
an argument:


and return the position of the matching items...

The position of what item in what sequence?

or loosen the
restrictions on position() in a for expression, or have a different
function where you could get the position in a for expression:

for $i in ../s
  if (...) then $i/position() else ()

This all depends on maintaining more context, and we've arguably got too much context-sensitivity already, especially in XSLT.

It would be much cleaner with a higher-order function, which you can write in XSLT/XPath 2.1:

<xsl:function name="f:index-of" as="xs:integer*">
<xsl:param name="sequence" as="item()*"/>
<xsl:param name="test" as="function(item()) as xs:boolean"/>
<xs:sequence select="for $i in 1 to count(sequence) return $i[$test($seq[$i])]"/>


f:index-of(../c, function($c){matches($c, $regex)})

Michael Kay

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.