This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: looping (was msxml install)
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: looping (was msxml install)
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Tue, 17 Oct 2000 10:43:06 +0100
- Reply-To: xsl-list at mulberrytech dot com
> 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