[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Reference to variable cannot be resolved.

Subject: RE: Reference to variable cannot be resolved.
From: "Martinez, Brian" <brian.martinez@xxxxxxxx>
Date: Fri, 14 Feb 2003 09:19:36 -0700
initial cannot be resolved
> From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx]
> Sent: Friday, February 14, 2003 8:13 AM
> Subject: Re:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.