[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Recursive for loop & xslt 2.0


Subject: [xsl] Recursive for loop & xslt 2.0
From: Israel Viente <israel.viente@xxxxxxxxx>
Date: Wed, 17 Jun 2009 15:07:23 +0300

Hi,

I used an example of a recursive for loop as below:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

<xsl:template match="/">

<html>
<head><title>Say Hello Ten Times!</title></head>
<body>
    <b>I am going to say hello Ten Times!</b>
<!-- begin_: Send_Loop_To_HTML -->
    <xsl:call-template name="for.loop">
     <xsl:with-param name="i">1</xsl:with-param>
     <xsl:with-param name="count">10</xsl:with-param>
    </xsl:call-template>
</body>
</html>

</xsl:template>


<!--begin_: Define_The_Output_Loop -->
  <xsl:template name="for.loop">

   <xsl:param name="i"      />
   <xsl:param name="count"  />

   <!--begin_: Line_by_Line_Output -->
   <xsl:if test="$i &lt;= $count">
      <br /> <b><xsl:value-of select="$i" />.</b>Hello world!
   </xsl:if>

   <!--begin_: RepeatTheLoopUntilFinished-->
   <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="for.loop">
          <xsl:with-param name="i">
              <xsl:value-of select="$i + 1"/>
          </xsl:with-param>
          <xsl:with-param name="count">
              <xsl:value-of select="$count"/>
          </xsl:with-param>
      </xsl:call-template>
   </xsl:if>

  </xsl:template>
</xsl:stylesheet>

As soon as I change the xsl:stylesheet/@version to "2.0" it stops
working as expected.

Can you please let me know what am I missing?

Thanks, Viente


Current Thread