RE: Repetition without a repeated source node

Subject: RE: Repetition without a repeated source node
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Tue, 29 Feb 2000 19:42:28 -0700
James Kerr wrote:
> I have an XML document that has a number as one of its attributes.  I
> would like to use that number as input into a loop and output 
> a block of HTML code the specified number of times.

In one template, do this...

  <xsl:call-template name="MakeHTMLBlock">
    <xsl:with-param name="num" select="number(@foo)"/>
  </xsl:call-template>

And then have this template...

<xsl:template name="MakeHTMLBlock">
  <xsl:param name="num"/>
  <xsl:if test="$num">
    <p>
      <b>some HTML</b>
    </p>
    <xsl:call-template name="MakeHTMLBlock">
      <xsl:with-param name="num" select="$num - 1"/>
    </xsl:call-template> 
  </xsl:if>
</xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread