Solved

Xsl:call-template

Posted on 2002-06-13
4
274 Views
Last Modified: 2011-09-20
Can the name attribute of a xsl:call-template be a xsl variable or xml tag?

I want the calling template name as a variable.

like
<xsl:call-template name="$tname"/> (But this will give an error)

How to achieve this?
0
Comment
Question by:dsraja
4 Comments
 
LVL 4

Expert Comment

by:vindevogel
ID: 7086936
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="D:\Projects\XML Framework\Untitled2.xsl"?>
<xml>
     <circle radius="10"/>
     <rectangle length="20" height="30"/>
</xml>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

     <xsl:template match="/xml">
          <xsl:for-each select="*">
               <xsl:apply-templates select="."/>
          </xsl:for-each>
     </xsl:template>
     
     <xsl:template match="circle">
          <p>I'm a circle with radius <xsl:value-of select="@radius"/></p>
     </xsl:template>
     
     <xsl:template match="rectangle">
          <p>I'm a rectangle</p>
     </xsl:template>
</xsl:stylesheet>




Something like this ??
0
 
LVL 6

Accepted Solution

by:
wbradney earned 20 total points
ID: 7165863
dsraja,

Calling a template whose name is decided at run-time is not possible in XSLT.

For more info see the spec at:
http://www.w3.org/TR/xslt#attribute-value-templates
http://www.w3.org/TR/xslt#named-templates

Regards,
WMB
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question