Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2006, 02:08 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Parameter to call another template

I'm trying to use a param to be the name of the next template I call:

For instance, this code works fine:

<xsl:template name="preprinted-form">
<fo:block>
<fo:table table-layout="fixed" space-before.optimum="0pt" space-after.optimum="0pt">
<xsl:call-template name="sales-order-columns"/>
     ....

I want to be able to do this:
<xsl:template name="preprinted-form">
<xsl:param name="column_prg"/>
<fo:block>
<fo:table table-layout="fixed" space-before.optimum="0pt" space-after.optimum="0pt">
    <xsl:call-template name="$column_prg"/>
     .....

So I can make the call:
<xsl:call-template name="preprinted-form">
<xsl:with-param name="column_prg" select="sales-order-columns"/>
</xsl:call-template>

Is this possible? Or anything like it?
Currently, this gives and error:
XTSE0280: Invalid QName {$column_prg}


Here is what sales-order-columns contains:
<xsl:template name="sales-order-columns">
        <fo:table-column column-width="0.8in" />
        <fo:table-column column-width="0.45in" />
        <fo:table-column column-width="1.35in" />
        <fo:table-column column-width="3.35in" />
        <fo:table-column column-width="0.70in" />
        <fo:table-column column-width="0.45in" />
        <fo:table-column column-width="0.80in" />
    </xsl:template>

The idea of this is because I am overlaying tables on top of one another. I want to be able to create this template so that it can be used on many business forms.

I am using saxon8.jar with jre1.5.0_06.
Reply With Quote
  #2 (permalink)  
Old October 27th, 2006, 03:08 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Nice idea but it doesn't work. The template name in call-template must be supplied literally as a QName.

If you want a dynamic call it can usually be achieved using apply-templates. Take a look at Dimitre Novatchev's FXSL library for an extreme example of what can be achieved without departing from the XSLT standard.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between call-template ,apply-templates vikkiefd XSLT 4 March 12th, 2008 05:09 AM
anyway to call a template with a lower precedence? ojasrege XSLT 3 November 30th, 2007 12:13 PM
how to use call-template result in a test? briforge XSLT 6 February 13th, 2006 06:54 PM
xsl:call-template name="$variable" problem chemi XSLT 1 October 6th, 2005 07:28 AM
import / call / template match Kabe XSLT 3 February 26th, 2004 11:31 AM



All times are GMT -4. The time now is 09:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.