Re: [xsl] using mode in multiple template match conditions will improve speed?

Subject: Re: [xsl] using mode in multiple template match conditions will improve speed?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 3 May 2007 10:19:37 +0100
	<xsl:template match="ANSWER">

you mean xsl:choose here
		<xsl:when test="@QTYPE='MC'">
			<div class="q_mc"><!-- different class names-->
				<xsl:apply-templates/>
			</div>
		</xsl:when>

unless you have very long lists its not likely to make so much
difference but an xsl:choose is almost certainly implemented by testing
each case in turn so expected time proportional to the number of
choices.

It looks like in this case you could do

	<xsl:template match="ANSWER">
	<div class="q_{lower-case(@QTYPE}">
				<xsl:apply-templates/>
			</div>
	</xsl:template>

which is a bit more processing on the instance (the lower case has to be
calculated rather than being a literal) but you avoid the conditional
processing decidibng which literal to use. Only way to see which is
quicker is to time it. I'd be surprised if the difference was
significant but I've been wrong before.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread