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 October 31st, 2011, 07:18 AM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default xsl elements

how can you pass in the name of an elelemnt as a template parameter

ie

<xsl:template name ="fpml.Currency">
<xsl:param name = "name" />
<xsl:param name = "currency"/>

<xsl:element name ="$name">
<xsl:attribute name = "currencyScheme">
<xsl:value-of select ="'http://www.fpml.org/ext/iso4217-2001-08-15'"/>
</xsl:attribute>

<xsl:value-of select = "$currency"/>
</xsl:element>
</xsl:template>


So as to call

<xsl:call-template name ="fpml.Currency">
<xsl:with-param name ="name" select ="'fpml:currency1'"/>
<xsl:with-param name ="currency" select ="$currency1"/>
</xsl:call-template>

<xsl:call-template name ="fpml.Currency">
<xsl:with-param name ="name" select ="'fpml:currency2'"/>
<xsl:with-param name ="currency" select ="$currency2"/>
</xsl:call-template>


thanks
 
Old October 31st, 2011, 07:28 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I think you are looking for
Code:
<xsl:element name="{$name}">...</xsl:element>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old October 31st, 2011, 07:29 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You want <xsl:element name="{$name}">

However in the above example you would get an error unless you had already defined the "fpml" prefix elsewhere.

Google for "Attribute Value Templates" for more on how to use the {}'s.

Sam
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old October 31st, 2011, 07:31 AM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default

brilliant.. thanks guys
anthony





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl reordering of elements new2xsl XSLT 12 April 2nd, 2010 03:38 PM
how t do comparision of elements in xsl suji XSLT 2 February 28th, 2008 12:27 PM
Adding elements from an XML to XSL. AjayLuthria XSLT 1 May 1st, 2007 12:12 PM
cdata-section-elements in xsl:output ROCXY XSLT 1 March 2nd, 2006 11:44 AM
Dynamically Finding Elements in XSL tclancy XSLT 2 March 1st, 2006 03:25 PM





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