[xsl] calling template with name passed in a variable

Subject: [xsl] calling template with name passed in a variable
From: Piotr Dobrogost <pd@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Dec 2009 01:07:07 +0100
Hi

Can I call a template passing its name dynamically (by means of select or variable)?

I'd like to do something like this

<xsl:template name="MyTypeX">
  (...)
</xsl:template>

<xsl:template name="MyTypeY">
  (...)
</xsl:template>

<xsl:param name="InPlaceTypesList" as="element()*">
  <type>MyTypeX</type>
  <type>MyTypeY</type>
</xsl:param>

<xsl:template match="xsd:element[@type=$InPlaceTypesList]">
  <xsl:call-template name="@type"/> // <-- error line
</xsl:template>

Error at xsl:call-template on line 135 column 38 of xsd2perl.xsl:
  XTSE0020: Invalid QName {@type}


Regards Piotr Dobrogost

Current Thread