Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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.
 
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
 
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.




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





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