Re: [xsl] calling template with name passed in a variable

Subject: Re: [xsl] calling template with name passed in a variable
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 18 Dec 2009 13:33:13 -0800
2009/12/17 Piotr Dobrogost <pd@xxxxxxxxxxxxxxxxxxxxxxxxxx>:
> Hi
>
> Can I call a template passing its name dynamically (by means of select or
> variable)?

Have a look at FXSL, but bear in mind that all the good people
(telling you may not actually need this) could be right.


Also, in XSLT 2.1 / XPath 2.1 higher-order functions become official.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
I enjoy the massacre of ads. This sentence will slaughter ads without
a messy bloodbath.



>
> I'd like to do something like this
>
> <xsl:template name="MyTypeX">
> B (...)
> </xsl:template>
>
> <xsl:template name="MyTypeY">
> B (...)
> </xsl:template>
>
> <xsl:param name="InPlaceTypesList" as="element()*">
> B <type>MyTypeX</type>
> B <type>MyTypeY</type>
> </xsl:param>
>
> <xsl:template match="xsd:element[@type=$InPlaceTypesList]">
> B <xsl:call-template name="@type"/> // <-- error line
> </xsl:template>
>
> Error at xsl:call-template on line 135 column 38 of xsd2perl.xsl:
> B XTSE0020: Invalid QName {@type}
>
>
> Regards
> Piotr Dobrogost

Current Thread