conditional selection of decimal-format in xslt
- by Jose L Martinez-Avial
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