W3C

XQuery and XPath Functions and Operators Array Namespace Document

21 March 2017


1 Introduction

This document describes the namespace http://www.w3.org/2005/xpath-functions/array defined by the [XPath and XQuery Functions and Operators 3.1] specification. This namespace is conventionally identified by the namespace prefix array. This prefix is not pre-declared in XQuery 3.1. For updated information, please refer to the latest version of the [XPath and XQuery Functions and Operators 3.1] specification.

This document describes the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future. [XPath and XQuery Functions and Operators 3.1] is the only specification that may amend this namespace.

This document contains a directory of links to related resources, using RDDL (as defined in [Resource Directory Description Language (RDDL)]).

It is GRDDL-enabled (as defined in [Gleaning Resource Descriptions from Dialects of Languages (GRDDL)]), that is to say that a GRDDL-compliant processor can extract useful RDF (as defined in [Resource Description Framework (RDF): Concepts and Abstract Syntax]) representations of the information contained herein.

2 XQuery and XPath Array Functions

This section lists all of the functions defined by the [XPath and XQuery Functions and Operators 3.1] specification to be in the namespace reserved for certain array-related functions.

Functions are uniquely identified by the combination of namespace URI, local name, and arity (number of arguments). For the purpose of this document, functions having a common namespace URI and local name can be considered to form a function family. A function family can be uniquely identified with a URI of the form: “http://www.w3.org/2005/xpath-functions/array#name” where name is the local name of a function, such as “sort”: http://www.w3.org/2005/xpath-functions/array#sort.

The normative definitions of these functions are in the [XPath and XQuery Functions and Operators 3.1] specification. For convenience, a very brief, non-normative summary of each function is provided. For details, follow the link on the “Summary:” introductory text below each function.

append

append(array(*), item()*) as array(*)

Returns an array containing all the members of a supplied array, plus one additional member at the end.

filter

filter(array(*), function(item()*) as xs:boolean) as array(*)

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

flatten

flatten(item()*) as item()*

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

fold-left

fold-left(array(*), item()*, function(item()*, item()*) as item()*) as item()*

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

fold-right

fold-right(array(*), item()*, function(item()*, item()*) as item()*) as item()*

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

for-each

for-each(array(*), function(item()*) as item()*) 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.

for-each-pair

for-each-pair(array(*), array(*), function(item()*, item()*) as item()*) 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.

get

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

Returns the value at the specified position in the supplied array (counting from 1).

head

head(array(*)) as item()*

Returns the first member of an array, that is $array(1).

insert-before

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

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

join

join(array(*)*) as array(*)

Concatenates the contents of several arrays into a single array.

put

put(array(*), xs:integer, item()*) as array(*)

Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value.

remove

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

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

reverse

reverse(array(*)) as array(*)

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

size

size(array(*)) as xs:integer

Returns the number of members in the supplied array.

sort

sort(array(*)) as array(*)

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

sort(array(*), xs:string?, function(item()*) as xs:anyAtomicType*) 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.

subarray

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

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

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

tail

tail(array(*)) as array(*)

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

3 Normative References

These documents describe the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future.

XPath and XQuery Functions and Operators 3.1

4 Non-Normative References

Resource Directory Description Language (RDDL)
Gleaning Resource Descriptions from Dialects of Languages (GRDDL)
Resource Description Framework (RDF): Concepts and Abstract Syntax