RE: finite loop, incrementing, or...?

Subject: RE: finite loop, incrementing, or...?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 3 Feb 2000 10:12:17 -0000
> <tscmeta>
>   <frequency code="ANNUAL" />
>   <date year="1994" month="1" day="1" />
>   <date year="1998" month="12" day="31" />
> </tscmeta>
> 
> Desired output: 
> <table><tr><td>1994</td><td>1995</td><td>1996</td><td>1997</td
> ><td>1998</td>
> </tr></table>
> 
> Any solutions? 

There's a nice little extension function coming out in the next Saxon
release that will allow you to do

<table><tr>
<xsl:for-each select="s:range(date[1]/@year, date[2]/@year)">
  <td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr></table>

Meanwhile it has to be recursion. The principle is:

template do-range
  param from
  param to
  if $from<=$to
     <td><value-of $from></td>
     call-template do-range
        with-param from = $from+1
        with-param to = $to
     /call
  /if
/template

Mike Kay


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


Current Thread