Atomization

Atomization is the process of converting a sequence of items into a sequence of atomic values. Atomization is used by expressions whenever a sequence of atomic values is required.

Each item in a sequence is converted to an atomic value by applying the following rules:

  • If the item is an atomic value, then the atomic value is returned.
  • If the item is a node, its typed value is returned. The typed value of a node is a sequence of zero or more atomic values that can be extracted from the node. If the node has no typed value, then an error is returned.

Implicit atomization of a sequence produces the same result as invoking the fn:data function explicitly on a sequence.

For example, the following sequence contains a combination of nodes and atomic values:

("Some text", <anElement>More text</anElement>, 1001)

Applying atomization to this sequence results in the following sequence of atomic values:

("Some text", "More text", 1001)

The following XQuery expressions use atomization to convert items into atomic values:

  • Arithmetic expressions
  • Comparison expressions
  • Function calls with arguments whose expected types are atomic
  • Cast expressions