Re: [xsl] Several rules vs a single rule with a choose operator

Subject: Re: [xsl] Several rules vs a single rule with a choose operator
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Sun, 29 Jul 2001 10:29:23 GMT
In terms of speed, I doubt there is much in it - in general XSLT
processors get slower as you give them more templates to look at, but
that is not a universal law, just a feature of the algorithms curently
in use.  If I had to guess I would pick the 'choose' variant, though I
would want to know what the node-test and conditions look like.

If the difference is *really* important to you then you need to run a
test with the real system, as you are quite likely to get different
answers according to exactly what the rest of your stylesheet
contains, what the node tests and conditions actually are, and what is
in the input (how many times this template is fired in comparison to
the rest).  You might even get different answers on different
machines.

My advice would be to choose the method that is going to be easiest to
change - probably the separate templates route.  As to performance, it
is true for most software systems that time spent getting the overall
design right is much more valuable than time spent on the minute
details of implementation.  In short, stop worrying about it.

>Hello, friends.
>
>How do you think, which of the following two approaches
>is more effective (particularly, for MSXML):
>
>  <xsl:template match="node-test[condition2]" priority="2">

You only need the priority if condition1 and condition2 are not
mutually exclusive.  In which case I wonder why you are not testing
the common part in the 'choose' method?

>    result2
>  </xsl:template>
>  <xsl:template match="node-test[condition1]" priority="1">
>    result1
>  </xsl:template>
>  <xsl:template match="node-test">
>    result0
>  </xsl:template>
>
>or
>
>  <xsl:template match="node-test">
>    <xsl:choose>
>      <xsl:when test="condition2">result2</xsl:when>
>      <xsl:when test="condition1">result1</xsl:when>
>      <xsl:otherwise>result0</xsl:otherwise>
>    </xsl:choose>
>  </xsl:template>
>
>The effectiveness question is important in my case,
>since I employ a large set of template rules
>and, moreover, apply it several times per request.
>
>Thanks.

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

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


Current Thread