This is an error in XSLT 1.0, but permitted in 2.0.
The relevant 1.0 rule is in section 11.5:
It is an error if a binding established by an xsl:variable or xsl:param
element within a template shadows another binding established by an
xsl:variable or xsl:param element also within the template.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Hermann Stamm-Wilbrandt [mailto:STAMMW(_at_)de(_dot_)ibm(_dot_)com]
Sent: 30 March 2010 12:33
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] question on variable definition
Hello,
xsltproc complains about redefining variable v with an error.
saxon9he has no complaints and does a rewrite(?) of the variable.
From the spec:
http://www.w3.org/TR/xslt#variables
For any use of these variable-binding elements, there is a
region of the stylesheet tree within which the binding is
visible; within this region, any binding of the variable that
was visible on the variable-binding element itself is hidden.
Thus, only the innermost binding of a variable is visible.
The set of variable bindings in scope for an expression
consists of those bindings that are visible at the point in
the stylesheet where the expression occurs.
So saxon9he seems to assue the second definition of v as
innermost binding, while xsltproc seems to see both on the
same binding level.
What is the spec conforming behavior?
$ xsltproc -version
Using libxml 20626, libxslt 10117 and libexslt 813 xsltproc
was compiled against libxml 20626, libxslt 10117 and libexslt
813 libxslt 10117 was compiled against libxml 20626 libexslt
813 was compiled against libxml 20626 $ xsltproc m.xsl m.xsl
runtime error: file m.xsl line 8 element variable
xsl:variable : redefining v no result for m.xsl $ java -jar
saxon9he.jar -xmlversion:1.0 -xsl:m.xsl -s:m.xsl
-versionmsg:off ; echo <?xml version="1.0"
encoding="UTF-8"?>12 $ $ cat m.xsl <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
<xsl:variable name="v" select="1"/>
<xsl:value-of select="$v"/>
<xsl:variable name="v" select="2"/>
<xsl:value-of select="$v"/>
</xsl:template>
</xsl:stylesheet>
$
Mit besten Gruessen / Best wishes,
Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH Vorsitzender des
Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--