[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] null call of document function


Subject: RE: [xsl] null call of document function
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 9 Apr 2007 14:46:10 +0100

> Could you elaborate on the phrase "optimize away"? I 
> understood it all up until there.

If you write an expression and the result isn't used, the XSLT processor is
likely to generate code that doesn't actually evaluate the expression:
that's what I mean by optimizing it away. The same effect can occur at
run-time. For example, if you write

<xsl:if test="doc('a.xml') | doc('b.xml')">

then the xsl:if is testing whether the union of the two calls on doc() is
non-empty. There's a very good chance that the XSLT processor will evaluate
the first call, and if the result is non-empty it will decide that the test
is true and won't bother evaluating the second call on doc(). Which means
that if you're relying on side-effects caused by this call, you're going to
be disappointed.

Michael Kay
http://www.saxonica.com/


Current Thread
Keywords