RE: [xsl] how to estimate speed of a transformation

Subject: RE: [xsl] how to estimate speed of a transformation
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 12 Dec 2003 11:25:12 -0000
> On the other hand, if a template contains a variable 
> definition that does depend on template's parameters,
> 
> <xsl:template name="footer">
>   <xsl:variable name="doctitle" select="/book/descendant::title[1]"/>
> 
> the programmer should expect that the computation takes place 
> only once. 

I suspect you meant to say "that *doesn't* depend on template's
parameters". But this variable *does* depend on the parameters, in the
sense that it depends on the context node (leading "/" selects the root
of the tree containing the context node) and the context node is an
implicit parameter to every template.

This is, however, a case where some simple caching might be appropriate.

I said in a previous response that Saxon doesn't do any caching. I just
realized another case where it does cache: for xsl:number. Saxon
remembers the last result of <xsl:number> and under the right
conditions, evaluates it by adding one to the previous result. This
makes the performance of numbering a sequence of n nodes O(n) rather
than O(n^2). But I would have to look in the source code to tell you
exactly what the preconditions for this optimization are.

Michael Kay


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


Current Thread