> From: abbouh [mailto:abbouh@xxxxxxxxxxxxxxxxx]
> Sent: Tuesday, May 27, 2003 11:10 AM
> Subject: repetition
>
>
> i want to know how i can repeat an instruction in xsl
> for example i want to display text "toto" n time
> whithout repeating
> <xsl:text>toto</xsl:text> n time.
> thanks
XSLT doesn't have procedural loop counters, but you can use recursion to get
the same effect. At its simplest:
<xsl:template name="text-loop">
<xsl:param name="max-times" select="1"/>
<xsl:param name="i" select="0"/>
<xsl:if test="$i < $max-times">
<xsl:text>toto </xsl:text>
<xsl:call-template name="text-loop">
<xsl:with-param name="max-times" select="$max-times"/>
<xsl:with-param name="i" select="$i + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Usage:
<xsl:call-template name="text-loop">
<xsl:with-param name="max-times" select="5"/>
</xsl:call-template>
Output:
toto toto toto toto toto
hth,
b.
| please note new address and phone #'s effective may 19 |
| brian martinez brian.martinez@xxxxxxxxxxx |
| lead gui programmer 303.357.3548 |
| cheap tickets, part of trip network fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400 englewood, co 80111 |
| cendant travel distribution services http://www.cheaptickets.com/ |
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- repetition
- abbouh - Tue, 27 May 2003 12:58:51 -0400 (EDT)
- <Possible follow-ups>
- Martinez, Brian - Tue, 27 May 2003 14:56:21 -0400 (EDT) <=
- Onur Esnaf - Wed, 28 May 2003 10:09:26 -0400 (EDT)
- abbouh - Wed, 28 May 2003 10:28:00 -0400 (EDT)
|
|