Loading TOC...

fn:number

fn:number(
   [$arg as xs:anyAtomicType?]
) as xs:double

Summary

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 17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.

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

Example

fn:number($item1/quantity)
=> 5.0

fn:number($item2)
=> NaN

Assume that the context item is the xs:string "15".
fn:number() returns 1.5E1.

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