Subject: Re: [xsl] calling template with name passed in a variable From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 18 Dec 2009 16:07:54 -0500 |
Date: Fri, 18 Dec 2009 02:14:20 GMT From: David Carlisle <davidc@xxxxxxxxx> Subject: Re: [xsl] calling template with name passed in a variable Message-Id: <200912180214.nBI2EKee001410@xxxxxxxxxxxxxxxxxxx> ... why have a named template there?
To be able to call by template by name with template's name being equal to current value of @type.
...
The goal is to execute different code (have different template matched) for all xsd:elements with given @type's value from the $InPlaceTypesList list. But I would like to avoid writing by hand a separate match for each element of $InPlaceTypesList list like this;
<xsl:template match="xsd:element[@type='MyTypeX']"> code for THIS type </xsl:template> .... <xsl:template match="xsd:element[@type='MyTypeY']"> code for THIS type </xsl:template>
I would like be able to extend xsl easily by adding new types to InPlaceTypesList param and to add new templates handling these new types with templates' names being the same as the names of new types like this;
<xsl:param name="InPlaceTypesList" select="('MyTypeX','MyTypeY','MyNewType1','MyNewType2')"/>
<xsl:template name="MyNewType1"> code for THIS type </xsl:template>
<xsl:template name="MyNewType2"> code for THIS type </xsl:template>
To put this another way; I want to isolate adding templates (with purpose of handling new types) from code needed to invoke (match) them.
-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] calling template with nam, Piotr Dobrogost | Thread | Re: [xsl] calling template with nam, David Carlisle |
Re: [xsl] calling template with nam, Piotr Dobrogost | Date | RE: [xsl] calling template with nam, Piotr Dobrogost |
Month |