[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
or was that just a copy-paste error?
Joe
http://joe.fawcett.name
Re: [xsl] Parameters into variables
Subject: Re: [xsl] Parameters into variables From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx> Date: Fri, 10 Oct 2008 11:30:38 +0100 |
------------------------------------------------- From: "Joe Barwell" <jbar@xxxxxxxx> Sent: Friday, October 10, 2008 11:20 AM To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Parameters into variables
Hello,<with-param name="aCurrency" select="'NZD'" /> should be <xsl:with-param name="aCurrency" select="'NZD'" />
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'">€</xsl:when> <xsl:when test="$aCurrency='GBP'">£</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
or was that just a copy-paste error?
Joe
http://joe.fawcett.name
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Parameters into variables, Joe Barwell | Thread | Re: [xsl] Parameters into variables, Joe Barwell |
[xsl] Parameters into variables, Joe Barwell | Date | RE: [xsl] Parameters into variables, Michael Kay |
Month |
Keywords