fn:format-number
Formats a number as specified by a picture string and decimal format.
format-number($value as xs:numeric?, $picture as xs:string, $options as (xs:string | map(*))?:={}) ➔ xs:string
Arguments | ||||
| $value | xs:numeric? | The number to be formatted | |
| $picture | xs:string | Picture showing how the number is to be formatted | |
| $options | (xs:string | map(*))? | := {} | Name of a decimal format definition defined in the context |
Result | xs:string | |||
Namespace
http://www.w3.org/2005/xpath-functions
Links to W3C specifications
XPath 3.1 Functions and Operators
XPath 4.0 Functions and Operators
Saxon availability
Available in XPath 3.0, XSLT 3.0, XQuery 3.0, and later versions. Available in all Saxon editions. Available for all platforms.
Notes on the Saxon implementation
From Saxon 9.3 this function becomes available for XPath/XQuery as well as XSLT. The query prolog declarations for defining a decimal format in XQuery become available in Saxon 9.4.
The function rules were enhanced to allow formatting using exponential notation in the XPath 3.1 version of the specification. These changes are implemented since Saxon 9.7, and are available provided XPath 3.1 is enabled.
Changes for this function in the XPath 4.0 specification are available from Saxon 13:
-
The decimal format name can now be supplied as a value of type
xs:QName, as an alternative to supplying a lexical QName as an instance ofxs:string. -
Decimal format parameters can now be supplied directly as a map in the third argument, rather than referencing a format defined in the static context.
-
For selected properties including minus sign, exponent-separator, percent and per-mille, it is now possible to specify a single-character marker to be used in the picture string, together with a multi-character rendition to be used in the formatted output.