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

Re: How to make a loop ?

Subject: Re: How to make a loop ?
From: "cking" <cking@xxxxxxxxxx>
Date: Wed, 28 Jul 2004 13:05:24 +0200
xsl loop n times
Hi Alain,
you can do something like this:

<xsl:variable name="n-rows" select="5"/>

<xsl:template match="/">
  <html>
    <head>...</head>
    <body>
      <table>
        <tr>
          <xsl:call-template name="td-recursive"/>
        </tr>
      </table>
    </body>
  </html>
</xsl:template>

<xsl:template name="td-recursive">
  <xsl:param name="index" select="1"/>
  <td>
    <xsl:value-of select="info[$index]"/>
  </td>
  <xsl:if test="$index &lt; $n-rows">
    <xsl:call-template name="td-recursive">
      <xsl:with-param name="index" select="$index + 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

HTH,
Anton Triest

<quote from="Alain ROY">
  > Hi all,
  >
  > I want to make a table which may contain always the same number of rows (actually 5 but this can change later).
  > I want to fill this table with nodes values (let's say "info" for example). If there are less "info" nodes than the number of
rows
  > I chose for my table, I want to complete it with empty rows. If there are more "info" nodes than the number of rows of my table,
I
  > want to fill the table with only the n firsts info nodes values (n=number of rows of my table).
  > To fill my table I made a template for the rows. So I'd like to make a loop which will always call this template n times with a
  > parameter info[x] x=1..n
  >
  > What's the best way to do that ?
  >
  > Regards
  > AR
</quote>

Current Thread
  • How to make a loop ?
    • Alain ROY - Wed, 28 Jul 2004 04:46:29 -0500
      • cking - Wed, 28 Jul 2004 13:05:24 +0200 <=
        • cking - Wed, 28 Jul 2004 13:09:29 +0200
      • Mukul Gandhi - Wed, 28 Jul 2004 04:08:07 -0700 (PDT)
      • <Possible follow-ups>
      • A. ROY - Wed, 28 Jul 2004 09:19:40 -0500

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.