The XPath language provides explicit syntax for certain operations on arrays.
- These constructs can also be specified in terms of function primitives:
+ These constructs can all be specified in terms of function primitives:
-
+ An empty array can be constructed using either of the expressions
+ []
or array{}
. The effect is the same as the data model primitive
+ dm:empty-array(())
. Using user-visible functions it can be achieved
+ by calling array:build(())
or array:of-members(())
.
+ The expression array { $sequence }
constructs an array whose members
+ are the items in $sequence
. Every member of this array will
+ be a singleton item. The effect is the same as
+ array:build($sequence)
.
+ The expression [E1, E2, E3, ..., E/n]
constructs an array in which
+ E1
is the first member, E2
is the second member,
+ and so on. The result is equivalent to the expression
+ [] => array:append(E1) => array:append(E2) => ... => array:append(E/n))).
+ The lookup expression $array?*
returns the
+ sequence concatenation
+ of the members of the array. It is equivalent to calling
+ array:fold-left($array, (), fn($result, $next){ $result, $next })
.
+ The lookup expression $array?$N
, where $N
+ is an integer within the bounds of the array, is equivalent to
+ array:get($array, $N)
.
+ Similarly, applying the array as a function, $array($N)
,
+ is also equivalent to array:get($array, [$N])
+ The expression for member $m in $array return EXPR
+ is equivalent to array:for-each($array, fn($m){ EXPR })
.
+
+
+