[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: mode computation case

Subject: Re: mode computation case
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 03 Sep 2010 09:21:47 +0100
Re:  mode computation case
On 03/09/2010 03:16, ac wrote:

<xsl:template name="dispatch">
...
<xsl:choose>
<xsl:when test="@mode eq 'mode1'"><xsl:apply-templates
select="$nodetree" mode="mode1"></xsl:when
<xsl:when test="@mode eq 'mode2'"><xsl:apply-templates
select="$nodetree" mode="mode2"></xsl:when
<xsl:when test="@mode eq 'mode3'"><xsl:apply-templates
select="$nodetree" mode="mode3"></xsl:when
<xsl:when test="@mode eq 'mode4'"><xsl:apply-templates
select="$nodetree" mode="mode4"></xsl:when
<xsl:when test="@mode eq 'mode5'"><xsl:apply-templates
select="$nodetree" mode="mode5"></xsl:when
<xsl:when test="@mode eq 'mode6'"><xsl:apply-templates
select="$nodetree" mode="mode6"></xsl:when
<xsl:otherwise><xsl:apply-templates select="$nodetree"
mode="modeX"></xsl:otherwise>
</xsl:choose
...
<xsl:template>


Which already looks better, mostly since all modes in this example share the same tunneled parameters. The xsl:choose in "dispatch" is still somewhat clunky and an additional template is required. Therefore, I still propose that mode be made computable.

Regards,
ac

As has been said earlier in the thread, a template consisting mainly of a top level xsl:choose can almost always be usefully split up into separate templates, so here you can replace


here your dispach template is just implementing choosing code based on a mode attribute, ie it's implementing apply-templates "by hand" so things look simpler if you use apply-templates and let the xslt engine handle the dispaching.

replace xsl:call-template name="dispatch"> by
<xsl:apply-templates select="@mode">

and have

<xsl:template match="@mode[.='mode5']">
  <xsl;param name="nodetree" tunnel="yes"/>
  <xsl:apply-templates select="$nodetree" mode="mode5"/>
</xsl:template>

________________________________________________________________________
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.