[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: dynamic template naming XSL1.0 and Saxon 6.5.5

Subject: RE: dynamic template naming XSL1.0 and Saxon 6.5.5
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 19 Jun 2006 09:38:13 +0100
saxon call template
Saxon in fact has an extension element

saxon:call-template 

which is like xsl:call-template except that the "name" attribute is an AVT.
You don't need saxon:evaluate with this, just write

<saxon:call-template name="{$testVar/Configuration/Execute/@template}"/>

It's always better, of course, to work without extensions if you can. You
might like to look at Dimitre Novatchev's FXSL technique, which exploits the
ability of xsl:apply-templates to do dynamic dispatch. Rather than having a
variable holding the name of a template to be invoked, you have a variable
holding a node, typically a node with a unique name in some special
namespace; and then you do apply-templates on that node. By putting
different nodes in the variable, you can then cause different templates to
be invoked. 

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: news@xxxxxxxxxxx [mailto:news@xxxxxxxxxxx] 
> Sent: 19 June 2006 08:34
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  dynamic template naming XSL1.0 and Saxon 6.5.5
> 
> Hello List,
> 
> I want to call templates dynamicly. With dynamicly I mean, 
> that the templates name is determined at runtime.
> I doing this with xPathes stored in variables and the 
> saxon:evaluate function allready, and it works pretty fine.
> For instance. I have a variable with an stored string that I 
> want to be the templates name that should be executed.
> <xsl:variable name="testVar">
>   <Configuration>
>     <Execute template="templateName"/>
>   </Configuration>
> </xsl:variable>
> 
> If I try
> <xsl:call-template
> name="{saxon:evaluate($testVar/Configuration/Execute/@template)}"/>
> 
> I want a template with the name of 'templateName' to be executed. 
> <xsl:template name="temlpateName">
> ...
> </xsl:template>
> 
> I ll get a error message saying that the name of the called 
> template must be a valid Qname. :(
> 
> Does anyboy know how I could solve my problem?
> 
> Thanks & with best regards,
> Jan

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.