This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: performance with template and choose


--- "Michael Kay" <michael dot h dot kay at ntlworld dot com> wrote:

> 
> It looks as if MSXML3 isn't clever enough to spot that the different
> match patterns contain common subexpressions (e.g.
> 
> KH[@Type='401']/Key[@ProdID ='83' and translate(@StopVal, '-','')
> &lt;='20050911']
> 
> and so it is evaluating this subexpression several times for each
> candidate node. Your rewritten code avoids this by factoring out the
> subexpression so that there is a two-stage test.
> 
> Saxon won't do this optimization either, though in 7.2 I've started
> to
> put the logic in place to factor out common subexpressions.
> Interestingly, in Saxon 7.2 you could do this yourself with a memo
> function:
> 
> <xsl:template match="MD[z:type-1(.) and @ACPID='100']/@AAvl"
> > priority="1001" >
> 
> 
> <xsl:function name="z:type-1" saxon:memo-function="yes">
>   <xsl:param name="N"/>
>   <xsl:return select=boolean($N/parent::Key[@ProdID ='83' and
> translate(@StopVal, '-','')
> &lt;='20050911']/parent::KH[@Type='401'])"/>
> </xsl:function>
> 
> If a memo function is called twice with the same arguments, it
> remembers
> the result from the first time and avoids re-evaluating the function.


Wow.. Memoisation in XSLT! That's really great.

Mike, what exactly do you mean by "called twice with the same
arguments"?

For example, if the second time a corresponding argument is a different
node having the same string value (or which is "deep equal" to the
corresponding previous argument), will this be "the same argument" ?

Is there any reason (besides performance (side-effects)) why
memoisation should not be the default behaviour?



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]