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 | 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 April 12th, 2007, 12:26 PM
Authorized User
Points: 251, Level: 5
Points: 251, Level: 5 Points: 251, Level: 5 Points: 251, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Canada.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default Is this possible <call-template name="$param"/>?

Hi!

Let's say we have this simple XSLT

################## start XSLT ############

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="myTemplate"/>
  <xsl:template match="/">
    <xsl:call-template name="$myTemplate"/>
  </xsl:template>
  <xsl:template name="hello">
    <xsl:text>Hello</xsl:text>
  </xsl:template>
  <xsl:template name="world">
    <xsl:text>World</xsl:text>
  </xsl:template>
</xsl:stylesheet>

######### end XSLT ####

I want to be able to specify which template to use by giving the stylesheet directly its name.

I probably can do it some other way, if you have any ideas... Please respond.

Thanks,

Rushman

p.s. BTW, I'm still using XSLT 1.0 (Old Testament). I haven't converted yet to the New Testament (XSLT 2.0).

Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.
__________________
Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.
Reply With Quote
  #2 (permalink)  
Old April 12th, 2007, 12:48 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: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No, it's not possible.

You can generally do dynamic despatch by using xsl:apply-templates instead of call-template. Dimitre Novatchev's FXSL library develops this to a fine art. By using element nodes as surrogates for functions, apply-templates on a specific element node effects a call on the function that the element represents, thus giving you the basis for higher-order functional programming.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old April 12th, 2007, 01:04 PM
Authorized User
Points: 251, Level: 5
Points: 251, Level: 5 Points: 251, Level: 5 Points: 251, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Canada.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default

Thanks Mr. Kay for your quick response and your generous time.

- R -

Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.
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
embedded <xsl:element> into <xsl:with-param> petergoodman XSLT 2 July 9th, 2008 06:36 AM
doubt in using <xsl:template> rajatake XSLT 5 December 15th, 2006 08:09 AM
<input> to Param or Variable bonekrusher XSLT 1 October 11th, 2006 06:00 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
urgent: <mobile:call> control is being unfriendly kawak_zx7 General .NET 0 August 26th, 2004 11:36 PM



All times are GMT -4. The time now is 10:55 AM.


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