Skip to main content

XQuery Sequences Functions

XQuery Sequences Functions

The following table lists the commonly used sequence functions provided by XQuery.

NameDescription
count($seq as item()*)It is used to count the items in a sequence.
sum($seq as item()*)It is used to return the sum of the items in a sequence.
avg($seq as item()*)It is used to return the average of the items in a sequence.
min($seq as item()*)It is used to return the minimum valued item in a sequence.
max($seq as item()*)It is used to return the maximum valued item in a sequence.
distinct-values($seq as item()*)It returns select distinct items from a sequence.
subsequence($seq as item()*, $startingloc as xs:double, $length as xs:double)It is used to return a subset of provided sequence.
insert-before($seq as item()*, $position as xs:integer, $inserts as item()*)It is used to insert an item in a sequence.
remove($seq as item()*, $position as xs:integer)It is used to remove an item from a sequence.
reverse($seq as item()*)It is used to return the reversed sequence.
index-of($seq as anyatomictype()*, $target as anyatomictype())It returns indexes as integers to indicate availability of an item within a sequence.
last()It returns the last element of a sequence when used in predicate expression.
position()It is used in FLOWR expressions to get the position of an item in a sequence.
note

XSLT 2.0, XPath 2.0, and XQuery 1.0, share the same functions library.

A complete list of string functions is available at XSL Functions