conditional selection of decimal-format in xslt
Posted
by Jose L Martinez-Avial
on Stack Overflow
See other posts from Stack Overflow
or by Jose L Martinez-Avial
Published on 2010-03-12T23:01:57Z
Indexed on
2010/03/12
23:07 UTC
Read the original article
Hit count: 354
decimal-format
|xsl
Hi all, I'm trying to modify the decimal-format of a stylesheet based on certain information of an XML. More exaclty, I've a XML like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<REPORT>
<LANGUAGE>2</LANGUAGE>
<MYVALUE>123456.78</MYVALUE>
</REPORT>
I'm trying to define the decimal format as european if the language is 2, and default otherwse. So I've created the following template
<xsl:template match="REPORT">
<xsl:if test="$language=2">
<xsl:decimal-format decimal-separator=',' grouping-separator='.' />
</xsl:if>
<xsl:value-of select ="format-number(MYVALUE,'###.###,00')"/>
</xsl:template>
So it shows the number in european format or in standard format. But I'm getting the following error
xsl:decimal-format is not allowed in this position in the stylesheet!
If I try to put the decimal-format outside the template, then I get the message that the xsl:if is not allowed in this position in the sthylsheet. How can I change the decimal-format based in the XML?
Thanks Jose
© Stack Overflow or respective owner