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).
XQuery, XSLT 2.0, XSLT 3.0.
The input node.
The following XML contains items of type string:
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.
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: