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.
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--