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

RE: question about call-template

Subject: RE: question about call-template
From: "Carl Soane" <csoane@xxxxxxxxxxxxx>
Date: Mon, 31 Jan 2000 09:35:19 -0800
carl soane
It's not a completely clean solution, but how I achieve the "pass function
by reference" functionality you're looking for is through a switcher

Here's an example:

<xsl:template match="/">
    <xsl:call-template name="SWITCHER">
      <xsl:with-param name="Tpl">C</xsl:with-param>

<xsl:template name="SWITCHER">
 <xsl:param name="Tpl"></xsl:param>
  <xsl:when test="'B'=$Tpl">
   <xsl:call-template name="B"/>
  <xsl:when test="'C'=$Tpl">
   <xsl:call-template name="C"/>

<xsl:template name="B">
  The B Template

<xsl:template name="C">
  The C Template

Hope that helps.

-----Original Message-----
From:	owner-xsl-list@xxxxxxxxxxxxxxxx [SMTP:owner-xsl-list@xxxxxxxxxxxxxxxx]
On Behalf Of Reid M. Pinchback
Sent:	Saturday, January 29, 2000 5:40 PM
To:	XSL-List@xxxxxxxxxxxxxxxx
Subject:	question about call-template

[Apologies if anybody has seen this message before.  I'm pretty sure the
 listserv never sent it out the first time, but the archive on Mulberry's
 web site is broken and I can't check to make sure.]

I'm stumped.

I've learned how to write a template.  Ditto for calling a template by name,
and for passing parameters to a template.

I can't find a way to pass the *name* of a template to another template,
and then call that template by that name.  In other words, something like:

<xsl:template match="/">
    <xsl:call-template name="A">
      <xsl:with-param name="Tpl">B</xsl:with-param>

<xsl:template name="A">
  <xsl:param name="Tpl"></xsl:param>
  <xsl:call-template name="$Tpl"></xsl:call-template>

<xsl:template name="B">

Should this be possible?  I'm using IBM's XSL processor, but when I try
this I just get:

    "XSL Error: Could not find template named: '$Tpl'

Basically what I'm looking for is the same kind of functionality you get
in languages that allow you to pass a function by reference.  That way
I could create one template that did common processing, and pass a
specialized template to it to handle issues specific to the portion
of the document tree I'm trying to process (eg: create a generic reusable
table layout vs dealing with content-specific layout issues in the rows).

Thanks in advance for any assistance.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.