The xsl:decimal-format element defines the symbols and characters used by the format-number function to convert numbers to strings.
This element can be used more than once, but with certain limitations. Each element can have an optional name value assigned to it by using by the name attribute. However, you cannot repeat name values. Further, you can only omit the name attribute once.
This element does not effect the behavior of the xsl:number and the xsl:value-of elements when they are used to format a number for display in the output. Nor does it effect the string function which has a default procedure for converting numbers to strings.
The xsl:decimal-format element can only be a child of the xsl:stylesheet or the xsl:transform elements.
This is a self-closing element and it cannot contain any child elements or any content.
<xsl:decimal-format name="euro_currency" decimal-separator="," grouping-separator=".">
This code fragment shows how to format for European currency.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:decimal-format name="staff" digit="D" />
<xsl:template match="/">
<html>
<body>
<xsl:value-of select='format-number(123456789, "#.000000000")' />
<br />
<xsl:value-of select='format-number(123456789, "#.0")' />
<br />
<xsl:value-of select='format-number(0.123456789, "##%")' />
<br />
<xsl:value-of select='format-number(123456789, "################")' />
<br />
<xsl:value-of select='format-number(123456789, "D.0", "staff")' />
<br />
<xsl:value-of select='format-number(123456789, "$DDD,DDD,DDD.DD", "staff")' />
<br />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
123456789.000000000
123456789.0
12%
123456789
123456789.0
$123,456,789
In this second example, we define "D" to represent a digit and display several numeric format variations. This is the code for xslt_example_decimalformat.xsl.