fn:format-number( $value as xs:double, $picture as xs:string, [$decimal-format-name as xs:string] ) as xs:string
Returns a formatted string representation of value argument based on the supplied picture. An optional decimal format name may also be supplied for interpretation of the picture string. This is an XSLT function, and it is available in XSLT, XQuery 1.0-ml, and Server-Side JavaScript.
Parameters | |
---|---|
value |
The given numeric $value that needs to be formatted.
|
picture |
The desired string representation of the given number $value .
The picture string is a sequence of characters, in which the
characters represent variables such as, decimal-separator-sign,
grouping-sign, zero-digit-sign, digit-sign, pattern-separator,
percent sign and per-mille-sign. For details on the format-number
picture string, see
http://www.w3.org/TR/xslt20/#function-format-number.
|
decimal-format-name |
Represents a named <xsl:decimal-format> instruction.
It is used to assign values to the variables mentioned above
based on the picture string.
|
xquery version "1.0-ml"; fn:format-number(xs:integer("1000000"),"#,##0.00") => 1,000,000.00
xquery version "1.0-ml"; let $stylesheet := <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:decimal-format name="testformat" decimal-separator="."/> <xsl:template match="foo"> <xsl:sequence select="format-number(xs:float('1234.5'), '#,##0.00', 'testformat')"/> </xsl:template> </xsl:stylesheet> return xdmp:xslt-eval($stylesheet, document{<foo/>}) => 1,234.50
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.