DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4016>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4016

Lazy evaluation of variables causes problems when variables are set in global space





------- Additional Comments From [EMAIL PROTECTED]  2001-10-22 16:48 -------
XSLT was designed to be a functional, declarative language.  That means the 
processor has lots of choices about how to do things.  A variable can be 
optimized away through lazy evaluation if the variable is never referenced at 
run-time.  Imagine that you reference a variable only in a particular template, 
but that template is never instantiated because your source document contains no 
elements which would match.  Since the processor delays evaluation of variables 
until they're referenced, a variable can be defined in a stylesheet, but never 
evaluated.

Another way a variable can be optimized away is by substituting a constant value 
for it in the "compiled" repreentation fo the stylesheet.  Obviously, this can 
only happen if the variable evaluates to a constant, but that happens 
surprisingly often.

The XSLT recommendation doesn't really talk much about these issues.  I think 
rather than assume that "what a processor lets you do" is OK, you should only 
count on what the recommendation says is the required behavior of a conforming 
processor.  As processors mature, extension elements and functions which have 
any side-effects (other than generating to the result tree) will be more and 
more suspect, and you'll have a difficult time using stylesheets which rely on 
such behavior.

There have been a number of interesting threads on the Mulberry XSL list about 
this, including "problems" with processors other than Xalan.  For example, a 
user was complaining that Saxon was optimizing away a call to an extension 
function that was declared as returning "void".  Mike Kay responded that the 
optimization was legitimate, and that the stylesheet would never work correctly.

Reply via email to