[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: repetition

Subject: RE: repetition
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Tue, 27 May 2003 12:55:23 -0600
html text loop
> 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 &lt; $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)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.