XQuery Function Documentation

Search and Browse

http://www.w3.org/2005/xpath-functions/array

java:org.exist.xquery.functions.array.ArrayModule

Functions that operate on arrays

array:append

array:append($array as array(*), $appendage as item()*) as array(*)

Returns an array containing all the members of the supplied array, plus one additionalmember at the end.

Parameters:
$array The array
$appendage* The items to append
Returns:
array(*) : A copy of $array with the new member attached

array:filter

array:filter($array as array(*), $function as function(*)) as array(*)

Returns an array containing those members of the $array for which $function returns true.

Parameters:
$array The array to process
$function The function called on each member of the array
Returns:
array(*) : The resulting array

array:flatten

array:flatten($input as item()*) as item()*

Replaces an array appearing in a supplied sequence with the members of the array, recursively.

Parameters:
$input* The sequence to flatten
Returns:
item()* : The resulting sequence

array:fold-left

array:fold-left($array as array(*), $zero as item()*, $function as function(*)) as item()*

Evaluates the supplied function cumulatively on successive values of the supplied array.

Parameters:
$array The array to process
$zero* Start value
$function The function to call
Returns:
item()* : The result of the cumulative function call

array:fold-right

array:fold-right($array as array(*), $zero as item()*, $function as function(*)) as item()*

Evaluates the supplied function cumulatively on successive values of the supplied array.

Parameters:
$array The array to process
$zero* Start value
$function The function to call
Returns:
item()* : The result of the cumulative function call

array:for-each

array:for-each($array as array(*), $function as function(*)) as array(*)

Returns an array whose size is the same as array:size($array), in which each member is computed by applying $function to the corresponding member of $array.

Parameters:
$array The array to process
$function The function called on each member of the array
Returns:
array(*) : The resulting array

array:for-each-pair

array:for-each-pair($array1 as array(*), $array2 as array(*), $function as function(*)) as array(*)

Returns an array obtained by evaluating the supplied function once for each pair of members at the same position in the two supplied arrays.

Parameters:
$array1 The first array to process
$array2 The second array to process
$function The function to call for each pair
Returns:
array(*) : The resulting array

array:get

array:get($array as array(*), $index as xs:integer) as item()*

Gets the value at the specified position in the supplied array (counting from 1). This is the same as calling $array($index).

Parameters:
$array The array
$index The index
Returns:
item()* : The value at $index

array:head

array:head($array as array(*)) as item()*

Returns the first member of an array, i.e. $array(1)

Parameters:
$array The array
Returns:
item()* : The first member of the array

array:insert-before

array:insert-before($array as array(*), $position as xs:integer, $member as item()*) as array(*)

Returns an array containing all the members of the supplied array, with one additional member at a specified position.

Parameters:
$array The array
$position Position at which the new member is inserted
$member* The member to insert
Returns:
array(*) : A new array containing all members plus the new member

array:join

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

Concatenates the contents of several arrays into a single array

Parameters:
$arrays* The arrays to join
Returns:
array(*) : The resulting array

array:put

array:put($array as array(*), $position as xs:integer, $member as item()*) as array(*)

Returns an array containing all the members of the supplied array, with one additional member at the specified position.

Parameters:
$array The array
$position Position at which the new member is inserted
$member* The member to insert
Returns:
array(*) : A new array containing all members plus the new member

array:remove

array:remove($array as array(*), $positions as xs:integer*) as array(*)

Returns an array containing all the members of the supplied array, except for the members at specified positions.

Parameters:
$array The array
$positions* Positions of the members to remove
Returns:
array(*) : A new array containing all members from $array except the members whose position (counting from 1) is present in the sequence $positions

array:reverse

array:reverse($array as array(*)) as array(*)

Returns an array containing all the members of the supplied array, but in reverse order.

Parameters:
$array The array
Returns:
array(*) : The array in reverse order

array:size

array:size($array as array(*)) as xs:integer

Returns the number of members in the supplied array.

Parameters:
$array The array
Returns:
xs:integer : The number of members in the supplied array

array:sort

array:sort($array as array(*)) as array(*)

Returns an array containing all the members of the supplied array, sorted according to their typed value

Parameters:
$array The array to process
Returns:
array(*) : The sorted array

array:sort

array:sort($array as array(*), $collation as xs:string?) as array(*)

Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function.

Parameters:
$array The array to process
$collation? The collation to use for sorting
Returns:
array(*) : The sorted array

array:sort

array:sort($array as array(*), $collation as xs:string?, $key as function(*)) as array(*)

Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function.

Parameters:
$array The array to process
$collation? The collation to use for sorting
$key A function called for each array member which produces a sort key
Returns:
array(*) : The sorted array

array:subarray

array:subarray($array as array(*), $start as xs:integer) as array(*)

Gets an array containing all members from a supplied array starting at a supplied position, up to the end of the array

Parameters:
$array The array
$start The start index
Returns:
array(*) : A new array containing all members from $start

array:subarray

array:subarray($array as array(*), $start as xs:integer, $length as xs:integer) as array(*)

Gets an array containing all members from a supplied array starting at a supplied position, up to a specified length.

Parameters:
$array The array
$start The start index
$length Length of the subarray
Returns:
array(*) : A new array containing all members from $start up to the specified length

array:tail

array:tail($array as array(*)) as array(*)

Returns an array containing all members except the first from a supplied array.

Parameters:
$array The array
Returns:
array(*) : A new array containing all members except the first