Altova MapForce 2025 Enterprise Edition

Returns the value of node, converted to an xs:double. The only types that can be converted to numbers are Booleans, numeric strings, and other numeric types. Non-numeric input values (such as a non-numeric string) result in NaN (Not a Number).

mf-func-xpath2-number2

 

Languages

XQuery, XSLT 2.0, XSLT 3.0.

 

Parameters

Name

Type

Description

node

mf:atomic

The input node.

 

Example

The following XML contains items of type string:

 

<items>
  <item>1</item>
  <item>2</item>
  <item>Jingle Bells</item>
</items>

 

The mapping illustrated below attempts to convert all these strings to numeric values and write them to a target XML file. Notice that the data type of item in the target XML component is xs:integer while the source item is of xs:string data type. If the conversion is not successful, the item must be skipped and not copied to the target file.

mf-func-xpath2-number-example

XSLT 2.0 mapping

To achieve the mapping goal, a filter was used. The equal function checks if the result of the conversion is "NaN". If this is false, this indicates a successful conversion, so the item is copied to the target. The output of the mapping is as follows:

 

<items>
  <item>1</item>
  <item>2</item>
</items>

© 2018-2024 Altova GmbH