RE: [xsl] Reference to variable cannot be resolved.

Subject: RE: [xsl] Reference to variable cannot be resolved.
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Fri, 14 Feb 2003 14:08:09 -0000
You can do the same thing in other languages:
var c = "hi ";
function test() {
 var c = "hello ";

and you'll get 'hi hello hi'.
The global variable isn't changed by the local variable.

The main diference is that in xsl you can't change it's value, but you
can have several variables with the same name if they are in different

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mike Brown
Sent: Friday, February 14, 2003 11:12 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Reference to variable cannot be resolved.

David Carlisle wrote:
> > Explaining to people why that's legal, after telling them they can
> > 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
> 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
level and the other occurs in a template, they are different variables
the same name, whereas if both bindings occur at the top level, or if
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
binding that used that name was made at the top level and this binding
being made in a template.

No matter how you explain it, there's nothing really intuitive about it;
just the way things are; you have to state that the top-level bindings
global, yet overridable within a template, no?


  Mike J. Brown   |
  Denver, CO, USA |

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread