xsl-list
[Top] [All Lists]

Re: How to make a loop ?

2004-07-28 04:08:07
You can simulate an iterative loop with a recursive
template. for e.g.

<xsl:template name="iterate">
  <xsl:param name="x"/>
    
  <xsl:if test="$x &gt; 0">
    hello <!-- do something -->
    <xsl:call-template name="iterate">
      <xsl:with-param name="x" select="$x - 1" />     
    </xsl:call-template>
  </xsl:if>
</xsl:template>

You can call this template as -

<xsl:call-template name="iterate">
   <xsl:with-param name="x" select="5" />     
</xsl:call-template>

Regards,
Mukul

--- Alain ROY <ra81(_at_)email(_dot_)com> wrote:
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



                
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


<Prev in Thread] Current Thread [Next in Thread>