decimal-format_1-input.xml
<?xml version="1.0"?>
<products>
<product
id="p1" price="3250" stock="4" country="Denmark"/>
<product
id="p2" price="1000" stock="5" country="Germany"/>
<product
id="p3" price="1200" stock="19" country="Germany"/>
<product
id="p4" price="1500" stock="5" country="Australia"/>
<product
id="p5" price="1225" stock="3" country="Japan"/>
</products>
decimal-format_1-stylesheet.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:decimal-format
grouping-separator="," decimal-separator="." name="us"/>
<xsl:decimal-format
grouping-separator="." decimal-separator="," name="dk"/>
<xsl:output
indent="yes"/>
<xsl:template
match="/">
<product>
<xsl:for-each
select="products/product">
<xsl:choose>
<xsl:when
test="@country = 'Denmark'">
<product
id="{@id}" price="{format-number(@price, 'DKK #.##0,00', 'dk')}" country="{@country}"/>
</xsl:when>
<xsl:otherwise>
<product
id="{@id}" price="{format-number(@price, 'USD #,##0.00', 'us')}" country="{@country}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</product>
</xsl:template>
</xsl:stylesheet>
decimal-format_1-output.xml
<?xml version="1.0" encoding="UTF-8"?>
<product>
<product
id="p1" price="DKK 3.250,00" country="Denmark"/>
<product
id="p2" price="USD 1,000.00" country="Germany"/>
<product
id="p3" price="USD 1,200.00" country="Germany"/>
<product
id="p4" price="USD 1,500.00" country="Australia"/>
<product
id="p5" price="USD 1,225.00" country="Japan"/>
</product>
Defaults: grouping-separator="," and decimal-separator=".".
Updated 2009-03-19