Subject: RE: [xsl] Reference to variable cannot be resolved. From: "Martinez, Brian" <brian.martinez@xxxxxxxx> Date: Fri, 14 Feb 2003 09:19:36 -0700 |
> From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx] > Sent: Friday, February 14, 2003 8:13 AM > Subject: Re: [xsl] Reference to variable cannot be resolved. > > > Note that XSLT 2.0 (per the November 15 WD) changes this so that > > shadowing a local variable is not an error, though it is > discouraged: > > > > http://www.w3.org/TR/xslt20/#dt-shadows > > > This is really horrible. > > Why should a language support a practice that must be discouraged? The example given in the spec seems a bit misleading, because it really illustrates the restrictions of scope and not the practice of shadowing. The following is illegal in either spec: <xsl:template match="/"> <xsl:variable name="x" select="1"/> <xsl:variable name="x" select="$x+1"/> <xsl:value-of select="$x"/> </xsl:template> But in XSLT 1.0, you can do the following, which isn't much different from what 2.0 would allow, other than the initial binding is global instead of local: <xsl:variable name="x" select="1"/> <xsl:template match="/"> <xsl:if test="$x = 1"> <xsl:variable name="x" select="$x + 1"/> </xsl:if> <result><xsl:value-of select="$x"/></result> </xsl:template> Obviously it's complete nonsense. Perhaps the prevailing attitude is that implementations shouldn't have to prevent people from becoming victims of their own bad code. ;-) b. | brian martinez brian.martinez@xxxxxxxx | | senior gui programmer 303.708.7248 | | trip network, inc. fax 303.790.9350 | | 6436 s. racine cir. englewood, co 80111 | | http://www.cheaptickets.com/ http://www.trip.com/ | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: Re: Reference to vari, Michael Kay | Thread | Re: [xsl] Reference to variable can, Jeni Tennison |
RE: RE: [xsl] How to implement an a, Imrran Wahid | Date | RE: xslt core and intuition was RE:, Roger Glover |
Month |