This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Repetition without a repeated source node


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]