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

RE: call-template error

Subject: RE: call-template error
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 28 May 2007 13:01:13 +0100
RE:  call-template error
The name of a template being called must be a fixed string, just as when you
call a function or method in languages like C or Java. Variables can only be
used in XPath expressions, and the name attribute of call-template is not an
XPath expression.

You can often achieve a dynamic call by using apply-templates to some
suitable node.

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

> -----Original Message-----
> From: Vaduvoiu Tiberiu [mailto:vaduvoiutibi@xxxxxxxxx] 
> Sent: 28 May 2007 11:24
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  call-template error
> 
> On my site I have a couple of categories/menus. Each time 
> you're in a category it loads a different template(content) I 
> have a parameter $menu which has the value of the name of the 
> menu you are at on the site. So until now I had something like this:
> 
> <xsl:if test="$menu= sport">
> <xsl:call-template name="toolbox_sport"></xsl:call-template>
> </xsl:if>
> <xsl:if test="$menu= 'news">
> <xsl:call-template name="toolbox_news"></xsl:call-template>
> </xsl:if>
> <xsl:if test="$menu= recent">
> <xsl:call-template name="toolbox_recent"></xsl:call-template>
> </xsl:if>
> <xsl:if test="$menu= test">
> <xsl:call-template name="toolbox_test"></xsl:call-template>
> </xsl:if>
> 
> like this, it works. But then I though of making it more 
> simple like this:
> 
> <xsl:call-template name="toolbox_$menu"></xsl:call-template> 
> so basically it should only loads the template of the 
> selected menu. Thing is it doesn't work..I get 
> java.util.EmptyStackException:
> 
> I also tried creating a variable
> <xsl:variable name="tool">toolbox_<xsl:value-of 
> select="$menu"/></xsl:variable> and then calling the template 
> with the name="$tool"..also doesn't work. So why doesn't he 
> load it?? 10x
> 
> 
>        
> ______________________________________________________________
> ______________________Take the Internet to Go: Yahoo!Go puts 
> the Internet in your pocket: mail, news, photos & more. 
> http://mobile.yahoo.com/go?refer=1GNXIC

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.