I would like to call a templa开发者_如何学Pythonte based on an inbound parameter to an xsl stylesheet.
Using the parameter in the name attribute fails because $ is illegal in the context. Does this mean I have to use a xsl:choose to accomplish this?
If you want to call templates selected dynamically then you can usually do it using xsl:apply-templates rather than xsl:call-template. One very general way of doing this is to change each
<xsl:template name="n">
to
<xsl:template name="n" match="xsl:template[@name='n']">
and then change your invalid
<xsl:call-template name="$x"/>
to a legitimate
<xsl:apply-templates select="document('')/*/xsl:template[@name=$x]">
And pass the context item as a parameter if necessary.
However, if we knew more about the problem you are trying to solve, we might be able to suggest a better way of solving it.
Unless you use an XSLT processor like the commercial version of Saxon 9 where you have an extension instruction like http://www.saxonica.com/documentation/extensions/instructions/call-template.xml you will need to use xsl:choose.
精彩评论