(Indeed, I'm surprised your processor did not raise a warning when you
defined $foo twice in the same scope.)
This was disallowed in XSLT 1.0, and became allowed in XSLT 2.0. There were
strong arguments on both sides.
Now that it's permitted, I sometimes take advantage of it in constructs like
<xsl:variable name="seq" select="//x"/>
<xsl:variable name="seq" select="for $x in $seq return f($x)"/>
<xsl:variable name="seq" select="for $x in $seq return g($x)"/>
etc; using the same variable name for each stage in a sequence of computations.
But I still think it was a mistake to permit it, because beginners (and some
long-standing users like henry...) persist in trying to write XSLT the way they
write in procedural languages, and the restriction on shadowing variables was a
good way of catching their mistake.
Michael Kay
Saxonica
--~------------------------------------------------------------------
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>
--~--