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

Re: The evaluate function

Subject: Re: The evaluate function
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 3 Jan 2002 15:32:47 +0000
xsl evaluate function
Hi Trevor,

> Suppose I have a global variable:
> <xsl:variable name="x">
>    <something quite complicated >
> </xsl:variable>
> Now, if a clever XSLT processor sees that $x is only ever used in
> contexts where it is coerced to a string (e.g. in xsl:value-of) it
> can store only the string value and throw away the original tree
> fragment, saving memory and processing time. It might even calculate
> the string value directly without a tree at all.
> But as soon as we allow a general evaluate function, if the
> transform uses just one evaluate we can no longer do the above
> optimisation (and many others), because we cannot guarantee that
> some day the expression won't evaluate to something that uses $x as
> a node-set.

Just to check that I'm following you correctly. You're saying that
because the string passed to the evaluate() function could contain
anything, the processor can't know whether it contains a reference to
the $x variable in which the $x variable is treated as a node set, and
therefore cannot optimise the storage of the $x variable.

In other words, the processor no longer has the opportunity to scan
for uses of $x to work out what kind of value it is.

I can see that's a problem. But couldn't the user could help the
processor here by making the type of $x (and other global variables)

<xsl:variable name="x" type="xs:string">

Taking Evan's analogy with the descendant axis - you take a
performance hit if you use it, but either you don't care (because
performance is not a priority) or you have no choice because it is
only through the descendant operator that you can get what you need.
In the latter case, you take steps to minimize the impact.

The possible performance hit is, in my opinion, not enough of a reason
to omit a facility that makes the impossible possible.



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.