[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Parameters into variables

Subject: Re: Parameters into variables
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Fri, 10 Oct 2008 11:30:38 +0100
Re:  Parameters into variables
-------------------------------------------------
From: "Joe Barwell" <jbar@xxxxxxxx>
Sent: Friday, October 10, 2008 11:20 AM
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  Parameters into variables

Hello,

XSLT 1.0 (e.g. Firefox 3.0, etc.)

I have a template as follows:

<xsl:template name="getCurrencySymbol">
<xsl:param name="aCurrency" />
<xsl:choose>
<xsl:when test="$aCurrency='AUD'">A$</xsl:when>
<xsl:when test="$aCurrency='EUR'">&#x20AC;</xsl:when>
<xsl:when test="$aCurrency='GBP'">&#163;</xsl:when>
<xsl:when test="$aCurrency='NZD'">NZ$</xsl:when>
<xsl:when test="$aCurrency='USD'">US$</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>


At the top of my xsl stylesheet I want to put its value into a global variable:


<xsl:variable name="theCurrencySymbol">
<xsl:call-template name="getCurrencySymbol">
<with-param name="aCurrency" select="'NZD'" />
</xsl:call-template>
</xsl:variable>

But this does not work. Mangano (2003, p.120) shows that it will work if the template is called _without_ a parameter, and indeed I am able to do so successfully if I use a global variable, e.g. $baseCurrency, and change my getCurrencySymbol template so that it uses $baseCurrency (i.e. ignoring the $aCurrency parameter).

The problem is that I would like to be able to re-use my getCurrencySymbol template elsewhere, but with a specified parameter in its call rather than a global.

Is it really not possible to put the result of a template into a variable, if that template is being called using a parameter? I cannot think why such a minor distinction would be in the language.

Cheers!

Joe


<with-param name="aCurrency" select="'NZD'" /> should be <xsl:with-param name="aCurrency" select="'NZD'" />

or was that just a copy-paste error?


Joe
http://joe.fawcett.name


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.