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: finite loop, incrementing, or...?


> <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

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