# bea-xf:format-number

Converts $double-var to a string using the format pattern specified by $string-var.

If the value of $double-var is the empty sequence, the following error is displayed in the mapper:

    Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function format-number invocation: expected type [double@http://www.w3.org/2001/XMLSchema], given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

### Signatures

bea-xf:format-number(xs:double $double-var, xs:string $string-var) —> xs:string

### Arguments

Data Type | Argument | Description
--- | --- | ---
xs:double | $double-var | Represents the double number to be converted to a string.
xs:string | $string-var | Represents the pattern string. The format of this pattern is specified by the JDK 1.4.1 DecimalFormat class.

### Returns

Returns $double-var as a string based on the pattern specified by $string-var.

### Examples

#### Add Comma And More Decimal Places

Invoking format-number(xs:double(10002.45), "#,###0.000#") returns the string 1,0002.450 as shown in the following example query:

    <result>{bea-xf:format-number(xs:double(10002.45), "#,###0.000#")}</result>

The preceding query generates the following result:

    <result>1,0002.450</result>

### XQuery Compliance

Not a standard W3C XQuery function. This is a standard XSLT function.

Note: Only the two argument version of the standard XSLT function is supported.

Related Topics

W3C XSLT format-number function description.

JDK 1.4.1 DecimalFormat class description.