Solved

Xsl:call-template

Posted on 2002-06-13
4
273 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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