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

RE: Fwd: XSLT 2.0 Determining Position of Sequence Ite

Subject: RE: Fwd: XSLT 2.0 Determining Position of Sequence Item During "for expression" evaluation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 16 Mar 2007 21:10:57 -0000
RE:  Fwd: XSLT 2.0 Determining Position of Sequence Ite
> I have a simple xpath expression like this
> 
> for $x in (10 to 20) return $x
> 
> which simply return the sequence of integers between 10 and 20
> 
> Now, what if I wanted to return something like this instead 
> from the same sequence
> 
> 1 2 3 4 ... 11
> 
> I want to get access to the "position" of $x in the sequence, 
>  and also the total number of items in the sequence.
> 
> I tried something like this
> 
> for $x in (10 to 20) return $x/position()

XQuery has 

for $x at $p in (10 to 20) return $p

where $x will range from 10 to 20 while $p ranges from 1 to 11. But that's
not available in XPath. In XPath you have to resort to

for $p in 1 to 11 ...

But if you really want to use position(), you can go back to

<xsl:for-each select="10 to 20">
  ....


Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.