Subject: Re: [xsl] dynamic template invocation From: Jingjun Long <longjingjun@xxxxxxxxx> Date: Mon, 7 Sep 2009 23:39:04 +0800 |
This question reminds me a case of myself. Once I have requirement to import different XSL files according to different case like: <xsl:choose> <xsl:when test="$customer='a'"> <xsl:import href="customerA.xsl"/> </xsl:when> <xsl:when test="$customer='b'"> <xsl:import href="customerB.xsl"/> </xsl:when> <xsl:otherwise> <xsl:import href="default.xsl"/> </xsl:when> </xsl:choose> This does not work. According to my understanding, <xsl:import> action is executed first when combinate all xsl into a big XSL and other instruction like <xsl:choose> does not execute durring this term. They are evaluated later. (I think I still not so clear here) Your requirement seems similiar to this. For your command: <xsl:apply-templates mode="$mode"/> mode attribute is not evaluated durring the execution. Variable is not allowed here. Jingjun. 2009/9/7 ac <ac@xxxxxxxxxxxxx>: > Hi, > > Thank you Vyacheslav. > > That is a solution. > > Shouldn't it be part of the standard and shouldn't it also be available for > the mode parameter/attribute of <apply-templates/>? > > Is that part of proposed changes for XSLT v2.1? > > Thanks. > > Cheers, > ac > > >> >> http://www.saxonica.com/documentation9.2/extensions/instructions/call-templat e.html >> >> On Mon, Sep 7, 2009 at 10:06 AM, ac<ac@xxxxxxxxxxxxx> wrote: >> >>> >>> Hi, >>> >>> Is there, or shouldn't there be, a way to invoke templates dynamically as >>> in: >>> >>> <xsl:apply-templates mode="$mode"/> or >>> <xsl:call-template name="$name"/> >>> >>> rather than : >>> <xsl:choose> >>> <xsl:when test="$mode eq 'mode1'"><xsl:apply-templates mode="mode1"/> >>> <xsl:when test="$mode eq 'mode2'"><xsl:apply-templates mode="mode2"/> >>> <xsl:when test="$mode eq 'mode3'"><xsl:apply-templates mode="mode3"/> >>> ... >>> </xsl:choose> >>> or >>> <xsl:choose> >>> <xsl:when test="$mode eq 'mode1'"><xsl:call-template name="name1"/> >>> <xsl:when test="$mode eq 'mode2'"><xsl:call-template name="name2"/> >>> <xsl:when test="$mode eq 'mode3'"><xsl:call-template name="name3"/> >>> ... >>> </xsl:choose> >>> >>> as the <xsl:choose/> seems clumsy, verbose, repetitive, error-prone, and >>> counter productive, >>> especially when also passing invocation parameters (<xsl:with-param >>> .../>) ? >>> >>> A sample use case may be letting a user select in which mode she wishes >>> to >>> run a process, payroll for example, in trial, debug, report, post, >>> archive, >>> or purge modes. >>> >>> Thanks, >>> ac
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dynamic template invocati, ac | Thread | Re: [xsl] dynamic template invocati, Dimitre Novatchev |
Re: [xsl] dynamic template invocati, Dimitre Novatchev | Date | [xsl] replace lower to upper, Douglas Wade |
Month |