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

Newbie Question: call-template name="$variable"

Subject: Newbie Question: call-template name="$variable"
From: jkraai@xxxxxxxx
Date: Fri, 26 May 2000 09:27:06 -0500
call template name
Here's what I want to do:

<!-- For Each Recordset/Record ... -->
<xsl:template match="RECORD">
  <TR>
    <xsl:variable name="record_type" select="@TYPE"/>
    <xsl:call-template name="$record_type"/>
  </TR>
</xsl:template>

Using Xalan.

Get this error:
  XSL Error: Could not find template named: $record_type
  XSL Error: SAX Exception

Yes, templates of the right names are in the file.

Using this call-template statement:
  <xsl:call-template name="{$record_type}"/>
gives:
  XSL Error: Could not find template named: {$record_type}

Looking in the spec Sect. 6, it says that QNAMEs can be used 
in a call-template.  Variables are QNAMEs according to sect. 
2.4.

It seems that the QNAME isn't getting expanded early enough 
in the process.  Or that some variable bindings are happening 
a lot earlier than others.  Or something like that.  I can't 
find in the spec where this is disallowed.

Attempting to avoid using variables and going directly 
with a query, the example in sect. 7.6.2 Attribute Value 
Templates suggests to my hopeful psyche that I might be 
able to get away with something like this ...

Using this call-template statement:
  <xsl:call-template name="{@TYPE}"/>
gives:
  XSL Error: Could not find template named: {@TYPE}

Help!  Where am I going wrong?  Any suggestions for "the 
right" way to accomplish this w/o doing this:
  <xsl:variable name="record_type" select="@TYPE"/>
  <xsl:choose>
    <xsl:when test="$record_type='type1'>
      <xsl:call-template name="type1"/>
    </xsl:when>
    <xsl:when test="$record_type='type2'>
      <xsl:call-template name="type2"/>
    </xsl:when>
    <user:elipses>...</user:elipses>
    <xsl:otherwise>
      <xsl:call-template name="type2"/>
    </xsl:otherwise>
  </xsl:choose>
would be much appreciated.

Thanks,

--jim


------------------------------------------------------------------
You've received MurlMail! -- FREE, web-based email, accessible
anywhere, anytime from any browser-enabled device. Sign up now at
http://murl.com

Murl.com - At Your Service


 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.