XPath/XQuery join function

Summary

Concatenates the contents of several arrays into a single array.

Signature

array:join(
$arrays as array(*)*
) as array(*)

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

The function can be expressed as follows in XQuery:

				
declare function array:join($arrays as array(*)*) as array(*) {
   if (fn:empty($arrays))
      then []
   else if (fn:count($arrays) eq 1)
      then $arrays
   else 
      op:array-concat(fn:head($arrays), array:join(fn:tail($arrays)))
};
			

Examples

The expression array:join(()) returns [ ].

The expression array:join([1, 2, 3]) returns [1, 2, 3].

The expression array:join((["a", "b"], ["c", "d"])) returns ["a", "b", "c", "d"].

The expression array:join((["a", "b"], ["c", "d"], [ ])) returns ["a", "b", "c", "d"].

The expression array:join((["a", "b"], ["c", "d"], [["e", "f"]])) returns ["a", "b", "c", "d", ["e", "f"]].