This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: for loop


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]