RE: Newbie Question: call-template name="$variable"

Subject: RE: Newbie Question: call-template name="$variable"
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 26 May 2000 16:22:51 +0100
> Here's what I want to do:
> 
> <!-- For Each Recordset/Record ... -->
> <xsl:template match="RECORD">
>   <TR>
>     <xsl:variable name="record_type" select="@TYPE"/>
>     <xsl:call-template name="$record_type"/>
>   </TR>
> </xsl:template>
> 

Well you can't, sorry! The name has to be a QName, it can't be an
expression, and it can't be an attribute value template. A QName can't have
a "$" in it.

It looks to me as if your situation can be handled by changing
<xsl:call-template ...> to <xsl:apply-templates mode="x"/>, 
and replacing
<xsl:template name="type1"> by <xsl:template match="RECORD[@TYPE='type1']"
mode="x">

If you really need to call a named template decided at run-time, you can do
it in Saxon as 
<xsl:call-template name="{$rectype}" saxon:allow-avt="yes"/>

Mike Kay


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


Current Thread