Page 1 of 1

Error: Circular definition of variable ...

Posted: Mon Jul 28, 2008 5:21 pm
by phranck
Hi there!

In an XSL I have the following lines of code:

Code: Select all


  <xsl:variable name="hasSecondPage">
<xsl:choose>
<xsl:when test="$numberOfRounds = $numberOfRoundsToDisplayOnFirstPage and $numberOfRounds > $maxNumberOfRoundsOnFirstPage">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:when test="($numberOfRoundsToDisplayOnFirstPage < ($numberOfRounds + 1)) and ($numberOfRounds != $numberOfRoundsToDisplayOnFirstPage)">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="numberOfRoundsToDisplayOnFirstPage" as="xs:integer">
<xsl:variable name="rounds" select="/tourmatchesreport/tourmatchesreportitem/numberOfRoundsToDisplayOnFirstPage" as="xs:integer"/>
<xsl:choose>
<xsl:when test="$hasSecondPage = true()">
<xsl:value-of select="$rounds"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$rounds + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
If I do a transformation with the related XML this error occurs:

Code: Select all


SystemID: ~/Developer/theLeague/TennisFramework/tournamentMatchesReportRaster64.xsl
Description: Circular definition of variable hasSecondPage
The confusing thing is, if I change the definition of the variable 'numberOfRoundsToDisplayOnFirstPage' to the following code, everything is fine:

Code: Select all


<xsl:variable name="numberOfRoundsToDisplayOnFirstPage" select="/tourmatchesreport/tourmatchesreportitem/numberOfRoundsToDisplayOnFirstPage" as="xs:integer" />
What is wrong here?

Thanks for your help,
phranck

Re: Error: Circular definition of variable ...

Posted: Tue Jul 29, 2008 4:07 pm
by sorin_ristache
Hello,

The variable hasSecondPage was defined based on the variable numberOfRoundsToDisplayOnFirstPage which was defined based on hasSecondPage. This is a circular definition because the definition of hasSecondPage is based on itself. A definition in which the value of a variable is based on the value of the same variable is not allowed in XSLT.


Regards,
Sorin