Solved

Xsl:call-template

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now