XSL reference documentation generated from the W3C Recommendation 16 November 1999


XSL element decimal-format

Number Formatting

The format-number function converts its first argument to a string using the format pattern string specified by the second argument and the decimal-format named by the third argument, or the default decimal-format, if there is no third argument. The format pattern string is in the syntax specified by the JDK 1.1 DecimalFormat class. The format pattern string is in a localized notation: the decimal-format determines what characters have a special meaning in the pattern (with the exception of the quote character, which is not localized). The format pattern must not contain the currency sign (#x00A4); support for this feature was added after the initial release of JDK 1.1. The decimal-format name must be a QName, which is expanded as described in qname. It is an error if the stylesheet does not contain a declaration of the decimal-format with the specified expanded-name.

Note: Implementations are not required to use the JDK 1.1 implementation, nor are implementations required to be implemented in Java.

Note: Stylesheets can use other facilities in XPath to control rounding.

<decimal-format>
  name = qname
  decimal-separator = char
  grouping-separator = char
  infinity = string
  minus-sign = char
  NaN = string
  percent = char
  per-mille = char
  zero-digit = char
  digit = char
  pattern-separator = char
Model: EMPTY
</decimal-format>

The xsl:decimal-format element declares a decimal-format, which controls the interpretation of a format pattern used by the format-number function. If there is a name attribute, then the element declares a named decimal-format; otherwise, it declares the default decimal-format. The value of the name attribute is a QName, which is expanded as described in qname. It is an error to declare either the default decimal-format or a decimal-format with a given name more than once (even with different import precedence), unless it is declared every time with the same value for all attributes (taking into account any default values).

The other attributes on xsl:decimal-format correspond to the methods on the JDK 1.1 DecimalFormatSymbols class. For each get/set method pair there is an attribute defined for the xsl:decimal-format element.

The following attributes both control the interpretation of characters in the format pattern and specify characters that may appear in the result of formatting the number:

The following attributes control the interpretation of characters in the format pattern:

The following attributes specify characters or strings that may appear in the result of formatting the number: