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

RE: for loop

Subject: RE: for loop
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 18 Oct 2001 10:04:12 +0100
for loop michael kay xsl
> I have one node that holds a value of say 5 (this number
> could be any number
> 1-5 ).  I need to take that value and create 5 links that
> point to different
> locations.  Since the for-each is only a iterator across node
> sets, how
> would I handle this.

Assuming your number is in $number, the usual trick solution is

<xsl:for-each select="//node()[position() &lt;= $number]">
  <link/>
</xsl:for-each>

If you don't like that, the longwinded solution is a recursive named
template that takes $number as a parameter, outputs one link, and then calls
itself with the parameter set to ($number - 1), terminating when it reaches
zero.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.