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

Re: xsl:call-template question

Subject: Re: xsl:call-template question
From: Gerard Berthet <gberthet@xxxxxxxxxxxxxxx>
Date: Wed, 16 Feb 2000 23:04:09 -0800
xsl call template name
Here is the way I would solve it.
Regards,
Gerard

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                <!-- / Template -->

<xsl:variable name="nexttemplate">1</xsl:variable>

<xsl:template match="/">
<HTML>
<xsl:call-template name="buildpage">
        <xsl:with-param name="nexttemplate">buildbody</xsl:with-param>
</xsl:call-template>
</HTML>
</xsl:template>

<!-- buildpage Template -->

<xsl:template name="buildpage">
        <xsl:param name="nexttemplate">defaulttemplate</xsl:param>
        Invoking <xsl:value-of select="$nexttemplate"/>
        <xsl:choose>
        <xsl:when test="$nexttemplate = 'buildbody'">
          <xsl:call-template name="buildbody"/>
        </xsl:when>
        <xsl:when test="$nexttemplate = ''">
          <xsl:call-template name="defaulttemplate"/>
        </xsl:when>
        </xsl:choose>
</xsl:template>

<xsl:template name="defaulttemplate">
In defaulttemplate
</xsl:template>

<!-- buildbody Template -->

<xsl:template name="buildbody">
<BODY>
</BODY>
</xsl:template>
</xsl:stylesheet>

At 11:36 AM 2/16/00 -0800, you wrote:

Hello,

Is it possible to call a template and pass in as a parameter the name of the template you would like the called template to call?

Here's a (non-working) example of what I am trying to do:

<!-- / Template -->

<xsl:template match="/">
<HTML>
<xsl:call-template name="buildpage">
        <xsl:with-param name="nexttemplate">buildbody</xsl:with-param>
</xsl:call-template>
</HTML>
</xsl:template>

<!-- buildpage Template -->

<xsl:template name="buildpage">
        <xsl:param name="nexttemplate">defaulttemplate</xsl:param>
        <xsl:value-of select="$nexttemplate"/>
        <xsl:call-template name="{$nexttemplate}"/>
</xsl:template>

<!-- buildbody Template -->

<xsl:template name="buildbody">
<BODY>
</BODY>
</xsl:template>

I get the error "No named template "{$nexttemplate}" found" when the line
<xsl:call-template name="{$nexttemplate}"/>
is processed.  I am able to get the value of $nexttemplate though...

Thanks in advance for any help you can give me.

Joni

========================== Gerard Berthet XML Networks, Inc. Email: gberthet@xxxxxxxxxxxxxxx http://www.xmlnetworks.com Tel: +1 (408) 356 - 5549 Cell: +1 (408) 218 - 1178 Fax: +1 (408) 356 - 0136


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



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.