Loading TOC...


   [arg as xs.anyAtomicType?]
) as Number


Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double. If $arg is the empty sequence or if $arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002].

Calling the zero-argument version of the function is defined to give the same result as calling the single-argument version with an argument of ".". That is, fn:number() is equivalent to fn:number(.).

If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context item after atomization, is converted to an xs:double following the rules of Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.

arg The value to be returned as an xs:double value.


var item1 = fn.head(xdmp.unquote('<a><quantity>5.0</quantity></a>')).root
=> 5

var item1 = fn.head(xdmp.unquote('<a><quantity>5.0</quantity></a>')).root
=> NaN

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.