This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSL: For-Each Efficient or Not?
- From: Kevin Jones <kjjones at ntlworld dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 1 Jul 2002 16:15:40 +0000
- Subject: Re: [xsl] XSL: For-Each Efficient or Not?
- References: <000301c2210c$32f47180$6401a8c0@pcukmka>
- Reply-to: xsl-list at lists dot mulberrytech dot com
On Monday 01 Jul 2002 2:32 pm, Michael Kay wrote:
> > We have been trying to determine whether using XSL:For-Each
> > is having an impact on the speed of our document publishing.
> > Some of my buddies don't want to use xsl:for-each because
> > they believe it causes the process to take a longer amount of
> > time than just doing a template match over and over. Is this
> > true or no? Is xsl:for-each a performance hog or does it and
> > template matching take the same amount of time?
>
> Measure it and see. The results will depend on which XSLT processor you
> are using. My guess is that there will be very little difference. The
> arguments against xsl:for-each are based on maintainability, not on
> performance.
>
And the complexity of the template match expressions in the stylesheets.
Simple tests on name or nodetype can be efficient but matches that involve
predicates are generally harder for a processor to index. These can cause
some processors to use sequential searching for a templates (slow for large
numbers of templates). I have seen the performance of some stylesheets
completely cripled by use of complex matches, e.g.,
<xsl:template match="m:apply[child::*[position()=1 and name()='factorof']]">
So its very specific to a processor/stylesheet pair and complex tests are
better done in for-each/if blocks if performance is more important than
maintainability.
Kev.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list