Search

I have created a recursion template with the help of the recurstion.mov tutorial. It works like a charm.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes" />

<xsl:template match="/">
  <xsl:call-template name="recursion" />
</xsl:template>

<xsl:template name="recursion">
  <xsl:param name="count" select="0" />
  <xsl:value-of select="$count" />
  <xsl:if test="$count &lt; 50">
     <xsl:text>, </xsl:text>
     <xsl:call-template name="recursion">
       <xsl:with-param name="count" select="$count + 10" />
     </xsl:call-template>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

Now I want to create a variable and increment the variable once. Like this:

<xsl:param name="count"  select="0" />
<xsl:value-of select="$count" />
<xsl:param name="count"  select="$count + 1" />
<xsl:value-of select="$count" />

This is not working. I think it's because of the count variable already existing when I increment it. Does anyone know how I can make this work?

Another question:

How can I create a loop through a variable?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details