Please enable JavaScript to view this site.

Altova MapForce 2020 Professional Edition

Converts a number into a string. The function is available for XSLT 1.0, XSLT 2.0, Java, C#, C++ and Built-in execution engine.

fn-format-number

Argument

Description

value

Mandatory argument. Supplies the number to be formatted.

format

Mandatory argument. Supplies a format string that identifies the way in which the number is to be formatted. This argument is used in the same way as the format argument in the format-dateTime function.

decimal-point-format

Optional argument. Supplies the character to be used as the decimal point character. The default value is the full stop ( . ) character.

grouping-separator

Optional argument. Supplies the character used to separate groups of numbers. The default value is the comma ( , ) character.

 

Note:If the function’s output (i.e. result) is connected to a node of type other than string, the formatting may be lost as the value is cast to the target type. This automatic cast can be disabled by unchecking the Cast target values to target types check box in the component settings of the target component.

 

Format:

format := subformat (;subformat)?

 subformat := (prefix)? integer (.fraction)? (suffix)?

 prefix := any characters except special characters

 suffix := any characters except special characters

 integer := (#)* (0)* ( allowing ',' to appear)

 fraction := (0)* (#)* (allowing ',' to appear)

 

The first subformat is used for formatting positive numbers, and the second subformat for negative numbers. If only one subformat is specified, then the same subformat will be used for negative numbers, but with a minus sign added before the prefix.

 

Special Character

default

Description

zero-digit

0

A digit will always appear at this point in the result

digit

#

A digit will appear at this point in the result string unless it is a redundant leading or trailing zero

decimal-point

.

Separates the integer and the fraction part of the number.

grouping-separator

,

Separates groups of digits.

percent-sign

%

Multiplies the number by 100 and shows it as a percentage.

per-mille

Multiplies the number by 1000 and shows it as per-mille.

 

The characters used for decimal-point-character and grouping-separator are always "." and "," respectively. They can, however, be changed in the formatted output, by mapping constants to these nodes.

fn-form-nr

The result of the format number function shown above.

 

The decimal-point character was changed to a "+".

The grouping separator was changed to a "-"

fn-form-nr2

 

Rounding

The rounding method used for this function is "half up", e.g. the value gets rounded up if the fraction is greater than or equal to 0.5. The value gets rounded down if the fraction is less than 0.5. This method of rounding only applies to generated code and the built-in execution engine.

 

In XSLT 1.0, the rounding mode is undefined. In XSLT 2.0, the rounding mode is "round-half-to-even".

 

Number

Format String

Result

1234.5

#,##0.00

1,234.50

123.456

#,##0.00

123.46

1000000

#,##0.00

1,000,000.00

-59

#,##0.00

-59.00

1234

###0.0###

1234.0

1234.5

###0.0###

1234.5

.00025

###0.0###

0.0003

.00035

###0.0###

0.0004

0.25

#00%

25%

0.736

#00%

74%

1

#00%

100%

-42

#00%

-4200%

-3.12

#.00;(#.00)

(3.12)

-3.12

#.00;#.00CR

3.12CR

© 2019 Altova GmbH