[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: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Fri, 14 Feb 2003 12:09:22 -0000
reference can not be resolved
As I understand it, variables are scoped using a 'variable stack' - when a new template is matched, a new 'layer' is added to the stack that will contain the variables declared in that template.  Should a new template be called/applied in the middle of that template, then a new layer is added to the stack.  As each template ends, so a layer is popped off the stack.  Therefore only the variables at the top of the 'variable stack' are in scope.

Of course, variables that are defined as top-level-elements are handled slightly differently, as they are in scope at all times, but will be overridden by variables with same name in the current template should a conflict occur.

(this is just from a very limited knowledge of compilers - Im presuming its the same in xslt processors)

cheers
andrew

> -----Original Message-----
> From: Mike Brown [mailto:mike@xxxxxxxx]
> Sent: 14 February 2003 11:12
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Reference to variable cannot be resolved.
> 
> 
> David Carlisle wrote:
> > 
> > 
> > > Explaining to people why that's legal, after telling them 
> they can only
> > > assign x once, is a nice challenge :)
> > 
> > You can only assign a value to a variable once but you can have two
> > variables with the same name, but only one in scope at any 
> point in the
> > program.
> 
> 2 buts in one sentence... you're sounding like me now. One 
> possible reading of
> your explanation would be that when one variable binding 
> occurs at the top
> level and the other occurs in a template, they are different 
> variables with
> the same name, whereas if both bindings occur at the top 
> level, or if both
> occur within a single template, they are binding the same variable.
> 
> Perhaps a simpler way to look at it is that the variable 
> binding element
> (xsl:variable or xsl:param) is just creating/importing an 
> object and giving it
> a name. The name is then in scope among all following 
> siblings and their
> descendants. The name can be one that is already in scope 
> only if the other
> binding that used that name was made at the top level and 
> this binding is
> being made in a template.
> 
> No matter how you explain it, there's nothing really 
> intuitive about it; it's
> just the way things are; you have to state that the top-level 
> bindings are 
> global, yet overridable within a template, no?
> 
> Mike
> 
> -- 
>   Mike J. Brown   |  http://skew.org/~mike/resume/
>   Denver, CO, USA |  http://skew.org/xml/
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.454 / Virus Database: 253 - Release Date: 10/02/2003
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.454 / Virus Database: 253 - Release Date: 10/02/2003
 

 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.