The function converts the num argument to a string using the format pattern string specified by the format_pattern and the decimal-format named by the decimal_format, 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 following describes the structure of the pattern.
The pattern consists of one or two subpatterns, first is for positive numbers and zero, second is for negative numbers. Two subpatterns are delimited by semicolon. If there is only one subpattern, - is prefixed to the positive subpattern.
Every subpattern consists of optional prefix characters followed by an integer part followed by an optional fraction part followed by an optional suffix characters.
Prefix and suffix characters are any Unicode characters except special formatting characters described below, while integer and fraction part consist only from that special formatting characters. (As an exception, special characters may appear in prefix in suffix parts if enclosed in single quotes.
If fractional present, it starts from '.' character, and only one '.' may occur in the subformat. Thus it is easy to find where each part begins.
By default, the following characters are treated as special when used in the parts of the subpattern:
Symbol | Meaning |
---|---|
0 | A digit, zero will be printed. 0 must be the last character of integer part. |
# | A digit, zero will not be printed. |
. | Placeholder for decimal separator in the beginning of fraction part. |
, | Placeholder for grouping separator. It may appear only in integer part. All commas except the last will be ignored. |
; | Separates formats. It may appear only once in the pattern. |
- | Placeholder for negative prefix. |
% | Indicates that the value must be multiplied by 100 and shown as percentage. |
? | Indicates that the value must be multiplied by 1000 and shown as per mille. |
Note that character '¤' have a special meahing in DecimalFormat of JDK 1.1, but not in XPATH.
The format pattern string may be in a localized notation. The decimal_format may determine what characters have a special meaning in the pattern (with the exception of the quote character, which is not localized). The decimal_format must be a QName, and a search will be performed for top-level <xsl:decimal-format> key whose "key" attribute is equal to decimal_format; all names will be expanded before the search. It is an error if the stylesheet does not contain a declaration of the decimal-format with the specified expanded name.
String