Search code examples
xmlxsltxslt-2.0

Variable - has not been declared (or its declaration is not in scope)


I've defined some variables in the same scope:

<xsl:variable name="disc" select="fn:number(a)"/>
<xsl:variable name="pvTotal" select="fn:number(b)"/>
<xsl:variable name="taxTotal" select="fn:number(c)"/>

And then I defined another variable in the same scope:

<xsl:variable name="pvUnitario" select="$pvTotal+$taxTotal-$disc"/>

But I get this error:

XPST0008: Variable taxTotal- has not been declared (or its declaration is not in scope)

What am I doing wrong?


Solution

  • Change

    <xsl:variable name="pvUnitario" select="$pvTotal+$taxTotal-$disc"/>
    

    to

    <xsl:variable name="pvUnitario" select="$pvTotal + $taxTotal - $disc"/>
    

    so that taxTotal is referenced rather than taxTotal-.