Solved

Xsl:call-template

Posted on 2002-06-13
4
271 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
Comment Utility
<?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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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. 
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

16 Experts available now in Live!

Get 1:1 Help Now