RE: looping (was msxml install)

Subject: RE: looping (was msxml install)
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 17 Oct 2000 10:43:06 +0100
> Also, I've got a loop question to ask. I've got this bit of XML code
> 
> <reference id="K132H" models="3"/>
> 
> What I want is to take the number of models (here 3) and write
> 
> <img src="img/d1.jpg"/>
> <img src="img/d2.jpg"/>
> <img src="img/d3.jpg"/>
> 
> to my output xhtml file... I can't seem to find a way to work 
> around a while-loop in XSLt. Any help? Thanks much in advance!

Use recursion. Write a named template that takes parameters called "first"
and "last", call it with first=1, last=3. Within the named template, do:

<img src="img/d{$first}.jpg"/>
<xsl:if test="$first!=$last">
   <xsl:call-template name="...">
      <xsl:with-param name="first" select="$first + 1"/>
      <xsl:with-param name="last" select="$last"/>
   </xsl;call-template>
</xsl:if>


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


Current Thread