Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Variables and Parameters (9/14) >

Circular definitions

A circular definitions occur in documents if a value of variable is dependent on its own value. These definitions can occur in global variables and other more advanced XSLT constructs, but not in local variables. In local variables we would get different error - variable not declared - if we try to achieve circularity.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>
            <xsl:variable  name="xxx"
                        select="$yyy + 5"/>
            <xsl:variable  name="yyy"
                        select="$zzz + 5"/>
            <xsl:variable  name="zzz"
                        select="$xxx + 5"/>

            <xsl:template  match="/aaa">
                  <xsl:value-of  select="$xxx"/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

Error:


error - XTDE0640
Circular definition of variable xxx


Transformation failed: Run-time errors were reported


Previous chapter: Named-Templates
Next chapter: Stylesheet Functions
Previous page: Storing parts of XML document to a variable
Next page: Sending parameters to templates