saxon:array-member

Returns an external object intended for use as a member of a newly constructed array.

array-member($value as item()*) ➔ jt:com.saxonica.functions.extfn.ArrayMemberValue

Arguments

 

$value

item()*

The value to be used as an array member

Result

jt:com.saxonica.functions.extfn.ArrayMemberValue

Namespace

http://saxon.sf.net/

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.8.

Notes on the Saxon implementation

Available since Saxon 9.8.

Details

This function can be used to assist in constructing arrays whose members are sequences rather than individual items.

For example, the expression array { (1 to $n) ! saxon:array-member(1 to $n) } (with $n = 4) constructs the array array{1, (1, 2), (1, 2, 3), (1, 2, 3, 4)}. Without this construct, there is no convenient way of constructing an array where (a) the number of members is not known statically, and (b) the members may be arbitrary sequences rather than single items.

The actual result of the function is an external object which is specially recognized by the internal function array:_fromSequence which underpins the XPath curly array constructor array{a, b, c} and also the extension instruction saxon:array. If this internal function recognizes an instance of com.saxonica.functions.extfn.ArrayMemberValue in its input sequence, then instead of adding it to the array as a member directly, it unwraps it to obtain the underlying sequence, and adds this sequence as the next member of the array.

See also the saxon:array-member extension instruction.