Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2009, 03:26 PM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using a Named Template within a Named Template

Im using XSLT 1.0 and im trying call a named template from within another named template. The catch is the internal named template that gets called, is getting called from a parameter passed to the outter named template.

Here is the code im using
-------------------------------------------------
Code:
<xsl:template name="makeElement">
<xsl:param name="imax3Element"/><xsl:param name="imax2Value"/><xsl:param name="translateFunc"/>
<xsl:variable name="tempVal">
<xsl:choose>
<xsl:when test="string-length($translateFunc)>0">
<xsl:call-template name="$translateFunc">
<xsl:with-param name="imax2"><xsl:value-of select="$imax2Value"/></xsl:with-param>
</xsl:call-template>
</xsl:when><xsl:otherwise>
<xsl:value-of select="$imax2Value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($tempVal)>0">
<xsl:element name="{$imax3Element}">
<xsl:value-of select="$tempVal"/></xsl:element>
</xsl:if></xsl:template>
<xsl:template name="translatePersonType">
<xsl:param name="imax2"/>
<xsl:choose>
<xsl:when test="$imax2= 'Subscriber'">S</xsl:when>
<xsl:when test="$imax2= 'Employee'">S</xsl:when>
<xsl:when test="$imax2= 'Dependent'">D</xsl:when>
<xsl:otherwise><xsl:value-of select="$imax2"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
so when the param translateFunc of the named template makeElement is equal to translatePersonType, it should call that named Template, otherwise it should not call any Named Template.

The place it is getting stuck is: <xsl:call-template name="$translateFunc"> It says it is not allowed to have a $ in the name?

Currently I just have all the Named Templates hard coded and check the values of the string, but I want to try and make it more generic so that I do not have to hand code it every time I add a new Named Template.

does anyone have any ideas?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Named template being called, to no effect (newb) sardaukar XSLT 2 June 22nd, 2007 07:40 AM
named anchors stekker XSLT 1 November 16th, 2006 05:03 AM
Named arguments Bob Bedell C# 2 March 19th, 2006 09:25 PM
Named Pipes bpe_xmind Visual C++ 0 February 5th, 2006 08:21 AM
Help for named template wu4 XSLT 2 October 18th, 2005 10:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.