Subject: Re: [xsl] The evaluate function From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 3 Jan 2002 15:32:47 +0000 |
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) explicit: <xsl:variable name="x" type="xs:string"> ... </xsl:variable> 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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] The evaluate function, Trevor Nash | Thread | Re: [xsl] The evaluate function, Trevor Nash |
RE: [xsl] Wishes for XSL revisions , Joerg Pietschmann | Date | [xsl] UTF-8 html output and links, Casadome, Francisco |
Month |