fn:data

Returns the result of atomizing a sequence. This process flattens arrays, and replaces nodes by their typed values.

Signatures

fn:data() as xs:anyAtomicType*
fn:data($arg as item()*) as xs:anyAtomicType*

Properties

The zero-argument form of this function is deterministic, context-dependent, and focus-dependent.

The one-argument form of this function is deterministic, context-independent, and focus-independent.

Rules

If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

The result of fn:data is the sequence of atomic values produced by applying the following rules to each item in $arg:

Error Conditions

A type error is raised [ERRFOTY0012] if an item in the sequence $arg is a node that does not have a typed value.

A type error is raised [ERRFOTY0013] if an item in the sequence $arg is a function item other than an array.

A dynamic error is raised if $arg is omitted and the context item is absent.

Notes

The process of applying the fn:data function to a sequence is referred to as atomization. In many cases an explicit call on fn:data is not required, because atomization is invoked implicitly when a node or sequence of nodes is supplied in a context where an atomic value or sequence of atomic values is required.

The result of atomizing an empty sequence is an empty sequence.

The result of atomizing an empty array is an empty sequence.

Examples

The expression data(123) returns 123.

The expression data((123, 456)) returns 123, 456.

The expression data([[1,2],[3,4]]) returns 1, 2, 3, 4.

let $para := 
<para>In a hole in the ground there lived a <term author="Tolkien">hobbit</term>.</para>
         

The expression data($para) returns xs:untypedAtomic("In a hole in the ground there lived a hobbit.").

The expression data($para/term/@author) returns xs:untypedAtomic("Tolkien").

The expression data(abs#1) raises error FOTY0013.