Numeric formatting

2 minutes to read Download PDF Edit

Behavior in your Mendix application

A number will be translated into XML untouched, except that any trailing zeroes will be stripped and the representation will always be in non-scientific notation. The used rounding mode is configured in the Project Settings.

XML Schema facets

How numbers in XML should be represented can be specified in an XSD (or WSDL) by using schema facets.

We currently support totalDigits and fractionDigits for numeric elements.

  • totalDigits: defines the maximum number of digits in the number (excluding the dot and minus sign)
  • fractionDigits: defines the maximum number of digits after the decimal dot

This means that if we encounter a number that does not match the required output format, we will round it so it does match. If it is not possible to represent the number correctly by formatting the number then it will simply be put in the XML as is. Example: An XSD specifies a maximum amount of digits of 3 but the number is 1000.

Mendix does not enforce compliance to these restrictions unless ‘validate against wsdl’ is enabled in web service calls, or ‘validate against schema’ is enabled in XML Export actions.

Orginal valueTotal digitsFraction digitsFormatted valueComment
20.00553undefined20 
20.0055undefined320.006 
0.0undefinedundefined0 
110.955553110.96 
-110.955553-110.96 
0.0000001undefined60 
99.993undefined100 
99.992undefined99.99Not possible to format correctly, so left untouched.
999.9921999.99Not possible to format correctly, so left untouched.
1.19E-17undefinedundefined0.0000000000000000119 

Known issue

There is currently a limitation on the way Float values are rendered to XML, when the XML schema requires a xsd:decimal.

If, in a web service call action, you pass a Float parameter with a large number of fraction digits using a simple or advanced parameter mapping, a higher number of digits is preserved than when using a Domain-to-XML mapping for the same purpose.