A RESTful browser for eXist Java-Based Function Modules


http://www.w3.org/2005/xpath-functions
A module with the XQuery/XPath Core Library Functions

abs($number as numeric?) numeric
Returns the absolute value of the argument $number. If the argument is negative returns -$number otherwise returns $number.
$numberThe number

Returns the absolute value of the argument

adjust-date-to-timezone($date as xs:date?) xs:date?
Adjusts the xs:date value $date to the implicit timezone of the current locale.
$dateThe date

Returns the adjusted date

adjust-date-to-timezone($date as xs:date?, $duration as xdt:dayTimeDuration?) xs:date?
Adjusts the xs:date value $date to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:date without a timezone.
$dateThe date
$durationThe duration

Returns the adjusted date

adjust-dateTime-to-timezone($date-time as xs:dateTime?) xs:dateTime?
Adjusts the xs:dateTime value $date-time to the implicit timezone of the current locale.
$date-timeThe date-time

Returns the adjusted date-time

adjust-dateTime-to-timezone($date-time as xs:dateTime?, $duration as xdt:dayTimeDuration?) xs:dateTime?
Adjusts the xs:dateTime value $date-time to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:dateTime without a timezone.
$date-timeThe date-time
$durationThe duration

Returns the adjusted date-time

adjust-time-to-timezone($time as xs:time?) xs:time?
Adjusts the xs:time value $time to the implicit timezone of the current locale.
$timeThe time

Returns the adjusted time

adjust-time-to-timezone($time as xs:time?, $duration as xdt:dayTimeDuration?) xs:time?
Adjusts the xs:time value $time to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:time without a timezone.
$timeThe time
$durationThe duration

Returns the adjusted time

avg($values as xdt:anyAtomicType*) xdt:anyAtomicType?
Returns the average of the values in the input sequence $values, that is, the sum of the values divided by the number of values.
$valuesThe values

Returns the average of the values in the input sequence

base-uri($uri as node()?) xs:anyURI?
Returns the value of the base URI property for $uri. If $uri is the empty sequence, the empty sequence is returned.
$uriThe URI

Returns the base URI from $uri

base-uri() xs:anyURI?
Returns the value of the base URI property for the context item.

Returns the base URI from the context item

boolean($items as item()*) xs:boolean
Computes the xs:boolean value of the sequence $items.
$itemsThe items

Returns the boolean value, ebv, of the items

ceiling($number as numeric?) numeric
Returns a value of the same type as the argument. Specifically, returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of the argument, $number.
$numberThe number

Returns the non-fractional number not less than $number

codepoint-equal($string-1 as xs:string?, $string-2 as xs:string?) xs:boolean?
Returns true or false depending on whether the value of $string-1 is equal to the value of $string-2, according to the Unicode code point collation.
$string-1The first string
$string-2The second string

Returns true() if the codepoints are equal, false() otherwise

codepoints-to-string($codepoints as xs:integer*) xs:string
Creates an xs:string from a sequence of code points. Returns the zero-length string if $codepoints is the empty sequence. If any of the code points in $codepoints is not a legal XML character, an error is raised
$codepointsThe codepoints as a sequence of xs:integer values

Returns the string constructed from the codepoints if valid

collection($collection-uris as xs:string*, ...) node()*
Returns the documents contained in the collections specified in the input sequence. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Documents contained in subcollections are also included.
$collection-urisThe collection-uris for which to include the documents

Returns the document nodes contained in or under the given collections

compare($string-1 as xs:string?, $string-2 as xs:string?) xs:integer?
Returns the collatable comparison between $string-1 and $string-2, -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned. Please remember to specify the collation in the context or use the three argument version if you don't want the system default.
$string-1The first string
$string-2The second string

Returns -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned.

compare($string-1 as xs:string?, $string-2 as xs:string?, $collation-uri as xs:string) xs:integer?
Returns the collatable comparison using $collation-uri between $string-1 and $string-2, -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$string-1The first string
$string-2The second string
$collation-uriThe relative collation URI

Returns -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned.

concat($atomizable-values as xdt:anyAtomicType?, ...) xs:string?
Accepts two or more xdt:anyAtomicType arguments, $atomizable-values, and converts them to xs:string. Returns the xs:string that is the concatenation of the values of its arguments after conversion. If any of the arguments is the empty sequence, the argument is treated as the zero-length string.
$atomizable-valuesThe atomizable values

Returns the concatenated values

contains($source-string as xs:string?, $substring as xs:string?) xs:boolean
Returns an xs:boolean indicating whether or not the value of $source-string contains (at the beginning, at the end, or anywhere within) at least one sequence of collation units that provides a minimal match to the collation units in the value of $substring, according to the default collation.
$source-stringThe source-string
$substringThe substring

Returns true() if $source-string contains $substring, false() otherwise

contains($source-string as xs:string?, $substring as xs:string?, $collation-uri as xs:string) xs:boolean
Returns an xs:boolean indicating whether or not the value of $source-string contains (at the beginning, at the end, or anywhere within) at least one sequence of collation units that provides a minimal match to the collation units in the value of $substring, according to the collation that is specified in $collation-uri.The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$source-stringThe source-string
$substringThe substring
$collation-uriThe collation URI

Returns true() if $source-string contains $substring, false() otherwise

count($items as item()*) xs:integer
Returns the number of items in the argument sequence, $items.
$itemsThe items

Returns the number of items in the argument sequence

current-date() xs:date
Returns the xs:date (with timezone) that is current at some time during the evaluation of a query or transformation in which fn:current-date() is executed.

Returns the date current within the query execution time span

current-dateTime() xs:dateTime
Returns the xs:dateTime (with timezone) that is current at some time during the evaluation of a query or transformation in which fn:current-dateTime() is executed.

Returns the date-time current within query execution time span

current-time() xs:time
Returns the xs:time (with timezone) that is current at some time during the evaluation of a query or transformation in which fn:current-time() is executed.

Returns the time current within query execution time span

data($items as item()*) xdt:anyAtomicType*
Returns the sequence of atomic values from the items in $items.
$itemsThe items

Returns the atomic values of the items in $items

dateTime($date as xs:date?, $time as xs:time?) xs:dateTime?
Creates an xs:dateTime from an xs:date, $date, and an xs:time, $time.
$dateThe date as xs:date
$timeThe time as xs:time

Returns the combined date and time as xs:dateTime

day-from-date($date as xs:date?) xs:integer?
Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of $date.
$dateThe date as xs:date

Returns the day component from $date

day-from-dateTime($date-time as xs:dateTime?) xs:integer?
Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of $date-time.
$date-timeThe date-time as xs:dateTime

Returns the day component from $date-time

days-from-duration($duration as xdt:dayTimeDuration?) xs:integer?
Returns an xs:integer representing the days component in the canonical lexical representation of the value of $duration. The result may be negative.
$durationThe duration as xs:dayTimeDuration

Returns the days component of $duration

deep-equal($items-1 as item()*, $items-2 as item()*) xs:boolean
Returns true iff every item in $items-1 is deep-equal to the item at the same position in $items-2, false otherwise. If both $items-1 and $items-2 are the empty sequence, returns true().
$items-1The first item sequence
$items-2The second item sequence

Returns true() if the sequences are deep-equal, false() otherwise

deep-equal($items-1 as item()*, $items-2 as item()*, $collation-uri as xs:string) xs:boolean
Returns true iff every item in $items-1 is deep-equal to the item at the same position in $items-2, false otherwise. If both $items-1 and $items-2 are the empty sequence, returns true(). Comparison collation is specified by $collation-uri. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$items-1The first item sequence
$items-2The second item sequence
$collation-uriThe collation URI

Returns true() if the sequences are deep-equal, false() otherwise

default-collation() xs:string
Returns the context's default collation. E.g. http://www.w3.org/2005/xpath-functions/collation/codepoint.

Returns the default collation from the context

distinct-values($atomic-values as xdt:anyAtomicType*) xdt:anyAtomicType*
Returns a sequence where duplicate values of $atomic-values, based on value equality, have been deleted.
$atomic-valuesThe atomic values

Returns the distinct values sequence

distinct-values($atomic-values as xdt:anyAtomicType*, $collation-uri as xs:string) xdt:anyAtomicType*
Returns a sequence where duplicate values of $atomic-values, based on value equality specified by collation $collation-uri, have been deleted.
$atomic-valuesThe atomic values
$collation-uriThe collation URI

Returns the distinct values sequence

doc($document-uri as xs:string?) node()?
Returns the document node of $document-uri. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.
$document-uriThe document URI

Returns the document node of $document-uri

doc-available($document-uri as xs:string?) xs:boolean
Returns whether or not the document, $document-uri, specified in the input sequence is available. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.
$document-uriThe document URI

Returns true() if the document is available, false() otherwise

doctype($doctype as xs:string+) node()*
Returns the document nodes of the documents based on the DOCTYPE.
$doctypeone or more DOCTYPE names

Returns the document nodes matching the DOCTYPE names

Deprecated: This function is eXist-specific and deprecated. It should not be in the standard functions namespace. Please use util:doctype() instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

document($document-uris as xs:string+, ...) node()*
Returns the documents specified in the input sequence. This function is specific to eXist and will be replaced with the corresponding fn:doc function. Collection URIs can be specified either as a simple collection path or an XMLDB URI. If the input sequence is empty, the function will load all documents in the database.
$document-urisThe document URIs

Returns the documents

Deprecated: Moved to the 'http://exist-db.org/xquery/xmldb' namespace since it conflicts with the XSLT 2.0 function. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

document-uri($document-node as node()?) xs:anyURI?
Returns the absolute URI of the resource from which the document node $document-node was constructed, if none such URI exists returns the empty sequence. If $document-node is the empty sequence, returns the empty sequence.
$document-nodeThe document node

Returns the document URI of $document-node

empty($items as item()*) xs:boolean
Returns true() if the value of $items is the empty sequence, false() otherwise.
$itemsThe item sequence

Returns true() if the empty sequence, false() otherwise

encode-for-uri($uri-part as xs:string?) xs:string
Escapes reserved characters in $uri-part by replacing it with its percent-encoded form as described in [RFC 3986]. If $uri-part is the empty sequence, returns the zero-length string.
$uri-partThe URI part to encode

Returns the URI part with reserved characters percent encoded

ends-with($source-string as xs:string?, $suffix as xs:string?) xs:boolean
Returns true if the string value of $suffix is a suffix of the string value of $source-string, false otherwise. If either $source-string or $suffix is the empty sequence, the empty sequence is returned.
$source-stringThe source-string
$suffixThe suffix

Returns true() if $suffix is suffix of $source-string, false() otherwise

ends-with($source-string as xs:string?, $suffix as xs:string?, $collation-uri as xs:string) xs:boolean?
Returns true if the string value of $suffix is a suffix of the string value of $source-string using collation $collation-uri, false otherwise. If either $source-string or $suffix is the empty sequence, the empty sequence is returned. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$source-stringThe source-string
$suffixThe suffix
$collation-uriThe collation URI

Returns true() if $suffix is suffix of $source-string, false() otherwise

error($qname as xs:QName) empty()
Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and the default message, 'An error has been raised by the query'.
$qnameThe qname

error($qname as xs:QName?, $message as xs:string) empty()
Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and $message.
$qnameThe qname
$messageThe message

error($qname as xs:QName?, $message as xs:string, $error-object as item()*) empty()
Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and $message with $error-object appended.
$qnameThe qname
$messageThe message
$error-objectThe error object

error() empty()
Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using the default qname, 'http://www.w3.org/2004/07/xqt-errors#err:FOER0000', and the default error message, 'An error has been raised by the query'.

escape-html-uri($html-uri as xs:string?) xs:string
Replaces all nonprintable ASCII characters in the string value of $html-uri by an escape sequence represented as a hexadecimal octet in the form %XX. If $html-uri is the empty sequence, returns the zero-length string.
$html-uriThe html URI

Returns all nonprintable ASCII characters in $html-uri encoded by escape sequences

escape-uri($uri as xs:string?, $escape-reserved as xs:boolean) xs:string
This function applies the URI escaping rules defined in section 2 of [RFC 2396] as amended by [RFC 2732], with one exception, to the string supplied as $uri, which typically represents all or part of a URI. The effect of the function is to escape a set of identified characters in the string. Each such character is replaced in the string by an escape sequence, which is formed by encoding the character as a sequence of octets in UTF-8, and then representing each of these octets in the form %HH, where HH is the hexadecimal representation of the octet. $escape-reserved indicates whether to escape reserved characters.
$uriThe URI
$escape-reservedThe escaped-reserved

Returns the identified characters in $uri encoded with escape sequences

exactly-one($items as item()*) item()
Returns the argument sequence, $items, if it contains exactly one item. Otherwise, raises an error.
$itemsThe item sequence

Returns the sole item in $items if it contains exactly one item. Otherwise, an error is raised.

exists($items as item()*) xs:boolean
Returns true if the argument $items is not the empty sequence, false otherwise.
$itemsThe item sequence

Returns true() if not the empty-sequence, false() otherwise

false() xs:boolean
Always returns the boolean value false

Returns false

floor($number as numeric*) numeric
Returns the largets number not greater than the value of $number. If $number is the empty sequence, returns the empty sequence.
$numberThe number

Returns the largets number without fraction part not greater than the value of $number

hours-from-dateTime($date-time as xs:dateTime?) xs:integer?
Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of $date-time.
$date-timeThe date-time as xs:dateTime

Returns the hours component from $date-time

hours-from-duration($duration as xdt:dayTimeDuration?) xs:integer?
Returns an xs:integer representing the hours component in the canonical lexical representation of the value of $duration. The result may be negative.
$durationThe duration as xs:dayTimeDuration

Returns the hours component of $duration

hours-from-time($time as xs:time?) xs:integer?
Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of $time.
$timeThe time as xs:time

Returns the hours component from $time

id($idrefs as xs:string*) element()*
Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $idrefs. If none is matching or $idrefs is the empty sequence, returns the empty sequence.
$idrefsThe IDREF sequence

Returns the elements with IDs matching IDREFs from $idref-sequence

id($idrefs as xs:string*, $node-in-document as node()) element()*
Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $idrefs and is in the same document as $node-in-document. If none is matching or $idrefs is the empty sequence, returns the empty sequence.
$idrefsThe IDREF sequence
$node-in-documentThe node in document

Returns the elements with IDs matching IDREFs from $idrefs in the same document as $node-in-document

idref($ids as xs:string*) node()*
Returns the sequence of element or attributes nodes with an IDREF value matching the value of one or more of the ID values supplied in $ids. If none is matching or $ids is the empty sequence, returns the empty sequence.
$idsThe ID sequence

Returns the elements with matching IDREF values from IDs in $ids

idref($ids as xs:string*, $node-in-document as node()) node()*
Returns the sequence of element or attributes nodes with an IDREF value matching the value of one or more of the ID values supplied in $ids. If none is matching or $ids is the empty sequence, returns the empty sequence.
$idsThe ID sequence
$node-in-documentThe node in document

Returns the elements with matching IDREF values from IDs in $ids in the same document as $node-in-document

implicit-timezone() xdt:dayTimeDuration
Returns the value of the implicit timezone property from the dynamic context.

Returns the implicit timezone daytime-duration from the dynamic context

in-scope-prefixes($element as element()) xs:string*
Returns the prefixes of the in-scope namespaces for $element. For namespaces that have a prefix, it returns the prefix as an xs:NCName. For the default namespace, which has no prefix, it returns the zero-length string.
$elementThe element

Returns the prefixes

index-of($source as xdt:anyAtomicType*, $search as xdt:anyAtomicType) xs:integer?
Returns a sequence of positive integers giving the positions within the sequence of atomic values $source that are equal to $search.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.
The items in the sequence $source are compared with $search under the rules for the 'eq' operator. Values of type xs:untypedAtomic are compared as if they were of type xs:string. Values that cannot be compared, i.e. the 'eq' operator is not defined for their types, are considered to be distinct. If an item compares equal, then the position of that item in the sequence $source is included in the result.
If the value of $source is the empty sequence, or if no item in $source matches $search, then the empty sequence is returned.
The first item in a sequence is at position 1, not position 0.
The result sequence is in ascending numeric order.
$sourceThe source sequence
$searchThe search component

Returns the sequence of positive integers giving the positions within the sequence

index-of($source as xdt:anyAtomicType*, $search as xdt:anyAtomicType, $collation-uri as xs:string) xs:integer?
Returns a sequence of positive integers giving the positions within the sequence of atomic values $source that are equal to $search.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.
The items in the sequence $source are compared with $search under the rules for the 'eq' operator. Values of type xs:untypedAtomic are compared as if they were of type xs:string. Values that cannot be compared, i.e. the 'eq' operator is not defined for their types, are considered to be distinct. If an item compares equal, then the position of that item in the sequence $source is included in the result.
If the value of $source is the empty sequence, or if no item in $source matches $search, then the empty sequence is returned.
The first item in a sequence is at position 1, not position 0.
The result sequence is in ascending numeric order. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$sourceThe source sequence
$searchThe search component
$collation-uriThe collation URI

Returns the sequence of positive integers giving the positions within the sequence

insert-before($target as item()*, $position as xs:integer, $inserts as item()*) item()*
Returns a new sequence constructed from the value of $target with the value of $inserts inserted at the position specified by the value of $position. (The value of $target is not affected by the sequence construction.)
If $target is the empty sequence, $inserts is returned. If $inserts is the empty sequence, $target is returned.
The value returned by the function consists of all items of $target whose index is less than $position, followed by all items of $inserts, followed by the remaining elements of $target, in that sequence.
If $position is less than one (1), the first position, the effective value of $position is one (1). If $position is greater than the number of items in $target, then the effective value of $position is equal to the number of items in $target plus 1.
$targetThe target
$positionThe position to insert before
$insertsThe data to insert

Returns the new sequence

iri-to-uri($iri as xs:string?) xs:string
This function converts an xs:string containing an IRI into a URI according to the rules spelled out in Section 3.1 of [RFC 3987]. It is idempotent but not invertible.
If $iri contains a character that is invalid in an IRI, such as the space character (see note below), the invalid character is replaced by its percent-encoded form as described in [RFC 3986] before the conversion is performed.
If $iri is the empty sequence, returns the zero-length string.
Since [RFC 3986] recommends that, for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings, this function must always generate hexadecimal values using the upper-case letters A-F.
Notes:
This function does not check whether $iri is a legal IRI. It treats it as an xs:string and operates on the characters in the xs:string.
The following printable ASCII characters are invalid in an IRI: "<", ">", " " " (double quote), space, "{", "}", "|", "\", "^", and "`". Since these characters should not appear in an IRI, if they do appear in $iri they will be percent-encoded. In addition, characters outside the range x20-x126 will be percent-encoded because they are invalid in a URI.
Since this function does not escape the PERCENT SIGN "%" and this character is not allowed in data within a URI, users wishing to convert character strings, such as file names, that include "%" to a URI should manually escape "%" by replacing it with "%25".
$iriThe IRI

Returns the URI

item-at($source as item()*, $index as xs:integer) item()?
Returns the item in $source that is located at the position specified by $index.
$sourceThe source sequence
$indexThe index of the item in the source sequence to return

Returns the item

Deprecated: This function is eXist-specific and deprecated. It should not be in the standard functions namespace. Use e.g. $x[1] instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

lang($lang as xs:string?) xs:boolean
Tests whether the language of the context item as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $lang. The behavior of the function if the second argument is omitted is exactly the same as if the context item (.) had been passed as the second argument. The language of the argument node, or the context item if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false().
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $lang is the empty sequence it is interpreted as the zero-length string.
$langThe language code

Returns true if the language code matches, false otherwise

lang($lang as xs:string?, $node as node()) xs:boolean
Tests whether the language of $node as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $lang. The behavior of the function if the second argument is omitted is exactly the same as if the context item (.) had been passed as the second argument. The language of the argument node, or the context item if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false().
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $lang is the empty sequence it is interpreted as the zero-length string.
$langThe language code
$nodeThe node

Returns true if the language code matches, false otherwise

last() xs:integer?
Returns the context size from the dynamic context. If the context item is undefined, an error is raised.

Returns the context size from the dynamic context

local-name($arg as node()?) xs:string
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, or a text node), the function returns the zero-length string.
Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name AccessorDM. This will be an xs:string whose lexical form is an xs:NCName.
$argThe node to retrieve the local name from

Returns the local name

local-name() xs:string
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, or a text node), the function returns the zero-length string.
Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name AccessorDM. This will be an xs:string whose lexical form is an xs:NCName.

Returns the local name

local-name-from-QName($arg as xs:QName?) xs:NCName?
Returns an xs:NCName representing the local part of $arg. If $arg is the empty sequence, returns the empty sequence.
$argThe QName

Returns the local name

lower-case($arg as xs:string?) xs:string
Returns the value of $arg after translating every character to its lower-case correspondent as defined in the appropriate case mappings section in the Unicode standard. For versions of Unicode beginning with the 2.1.8 update, only locale-insensitive case mappings should be applied. Beginning with version 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default case operations, which are full case mappings in the absence of tailoring for particular languages and environments. Every upper-case character that does not have a lower-case correspondent, as well as every lower-case character, is included in the returned value in its original form.
$argThe text to be converted to all lower-case characters

Returns the resulting lower-case text

match-all($nodes as node()*, $regular-expression as xs:string+, ...) node()*
Tries to match each of the regular expression strings passed in $regular-expression and all following parameters against the keywords contained in the old fulltext index. The keywords found are then compared to the node set in $nodes. Every node containing all of the keywords is copied to the result sequence.
$nodesThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index

Returns the sequence of all of the matching nodes

Deprecated: This function is eXist-specific and should not be in the standard functions namespace. Please use text:match-all() instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

match-any($nodes as node()*, $regular-expression as xs:string+, ...) node()*
Tries to match each of the regular expression strings passed in $regular-expression and all following parameters against the keywords contained in the old fulltext index. The keywords found are then compared to the node set in $nodes. Every node containing any of the keywords is copied to the result sequence.
$nodesThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index

Returns the sequence of all of the matching nodes

Deprecated: This function is eXist-specific and should not be in the standard functions namespace. Please use text:match-any() instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

matches($input as xs:string*, $pattern as xs:string) xs:boolean
The function returns true if $input matches the regular expression supplied as $pattern, if present; otherwise, it returns false.
If $input is the empty sequence, it is interpreted as the zero-length string.
Unless the metacharacters ^ and $ are used as anchors, the string is considered to match the pattern if any substring matches the pattern. But if anchors are used, the anchors must match the start/end of the string (in string mode), or the start/end of a line (in multiline mode).
Note:
This is different from the behavior of patterns in [XML Schema Part 2: Datatypes Second Edition], where regular expressions are implicitly anchored.
Please note that - in contrast - with the specification - this method allows zero or more items for the string argument.
An error is raised [err:FORX0002] if the value of $pattern is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.
$inputThe input string
$patternThe pattern

Returns true if the pattern is a match, false otherwise

matches($input as xs:string*, $pattern as xs:string, $flags as xs:string) xs:boolean
The function returns true if $input matches the regular expression supplied as $pattern as influenced by the value of $flags, if present; otherwise, it returns false.
The effect of calling this version of the function with the $flags argument set to a zero-length string is the same as using the other two argument version. Flags are defined in 7.6.1.1 Flags.
If $input is the empty sequence, it is interpreted as the zero-length string.
Unless the metacharacters ^ and $ are used as anchors, the string is considered to match the pattern if any substring matches the pattern. But if anchors are used, the anchors must match the start/end of the string (in string mode), or the start/end of a line (in multiline mode).
Note:
This is different from the behavior of patterns in [XML Schema Part 2: Datatypes Second Edition], where regular expressions are implicitly anchored.
Please note that - in contrast - with the specification - this method allows zero or more items for the string argument.
An error is raised [err:FORX0002] if the value of $pattern is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.
An error is raised [err:FORX0001] if the value of $flags is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.
$inputThe input string
$patternThe pattern
$flagsThe flags

Returns true if the pattern is a match, false otherwise

max($arg as xdt:anyAtomicType*) xdt:anyAtomicType?
Selects an item from the input sequence $arg whose value is greater than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double.
- Numeric and xs:anyURI values are converted to the least common type that supports the 'ge' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This function returns an item from the converted sequence rather than the input sequence.
If the converted sequence is empty, the empty sequence is returned.
All items in $arg must be numeric or derived from a single base type for which the 'ge' operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for purposes of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, then a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the largest value is made according to the collation that is used.The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.
$argThe input sequence

Returns the max value

max($arg as xdt:anyAtomicType*, $collation-uri as xs:string) xdt:anyAtomicType?
Selects an item from the input sequence $arg whose value is greater than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double.
- Numeric and xs:anyURI values are converted to the least common type that supports the 'ge' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This function returns an item from the converted sequence rather than the input sequence.
If the converted sequence is empty, the empty sequence is returned.
All items in $arg must be numeric or derived from a single base type for which the 'ge' operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for purposes of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, then a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the largest value is made according to the collation that is used.If the type of the items in $arg is not xs:string and $collation-uri is specified, the collation is ignored.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.
$argThe input sequence
$collation-uriThe collation URI

Returns the max value

min($arg as xdt:anyAtomicType*) xdt:anyAtomicType?
Selects an item from the input sequence $arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double.
- Numeric and xs:anyURI values are converted to the least common type that supports the 'le' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This function returns an item from the converted sequence rather than the input sequence.
If the converted sequence is empty, the empty sequence is returned.
All items in $arg must be numeric or derived from a single base type for which the 'le' operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the smallest value is made according to the collation that is used. The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.
$argThe input sequence

Returns the minimum value

min($arg as xdt:anyAtomicType*, $collation-uri as xs:string) xdt:anyAtomicType?
Selects an item from the input sequence $arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double.
- Numeric and xs:anyURI values are converted to the least common type that supports the 'le' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This function returns an item from the converted sequence rather than the input sequence.
If the converted sequence is empty, the empty sequence is returned.
All items in $arg must be numeric or derived from a single base type for which the 'le' operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the smallest value is made according to the collation that is used. If the type of the items in $arg is not xs:string and $collation is specified, the collation is ignored.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.
$argThe input sequence
$collation-uriThe collation URI

Returns the minimum value

minutes-from-dateTime($date-time as xs:dateTime?) xs:integer?
Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of $date-time.
$date-timeThe date-time as xs:dateTime

Returns the minutes component from $date-time

minutes-from-duration($duration as xdt:dayTimeDuration?) xs:integer?
Returns an xs:integer representing the minutes component in the canonical lexical representation of the value of $duration. The result may be negative.
$durationThe duration as xs:dayTimeDuration

Returns the minutes component of $duration

minutes-from-time($time as xs:time?) xs:integer?
Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of $time.
$timeThe time as xs:time

Returns the minutes component from $time

month-from-date($date as xs:date?) xs:integer?
Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $date.
$dateThe date as xs:date

Returns the month component from $date

month-from-dateTime($date-time as xs:dateTime?) xs:integer?
Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $date-time.
$date-timeThe date-time as xs:dateTime

Returns the month component from $date-time

months-from-duration($duration as xdt:yearMonthDuration?) xs:integer?
Returns an xs:integer representing the months component in the canonical lexical representation of the value of $duration. The result may be negative.
$durationThe duration as xs:yearMonthDuration

Returns the months component of $duration

name($arg as node()?) xs:string?
Returns the name of $arg as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace binding having no name), the function returns the zero-length string.
Otherwise, the value returned is fn:string(fn:node-name($arg)).
$argThe input node

Returns the name

name() xs:string?
Returns the name of the context item as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.
The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace binding having no name), the function returns the zero-length string.
Otherwise, the value returned is fn:string(fn:node-name($arg)).

Returns the name

namespace-uri($arg as node()?) xs:anyURI
Returns the namespace URI of the xs:QName of $arg.
If the argument is omitted, it defaults to the context node (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $arg is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name AccessorDM) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string.
$argThe input node

Returns the namespace URI

namespace-uri() xs:anyURI
Returns the namespace URI of the xs:QName of the context item.
The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $arg is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name AccessorDM) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string.

Returns the namespace URI

namespace-uri-for-prefix($prefix as xs:string?, $element as element()) xs:anyURI?
Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix.
If $element has an in-scope namespace whose namespace prefix is equal to $prefix, it returns the namespace URI of that namespace. If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace. Otherwise, it returns the empty sequence.
Prefixes are equal only if their Unicode code points match exactly.
$prefixThe namespace prefix
$elementThe element

Returns the namespace URI

namespace-uri-from-QName($arg as xs:QName?) xs:anyURI?
Returns the namespace URI for $arg. If $arg is the empty sequence, returns the empty sequence.
$argThe QName

Returns the namespace URI

nilled($arg as node()?) xs:boolean?
Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not an element node, returns the empty sequence. If the argument is the empty sequence, returns the empty sequence.
$argThe input node

Returns true if the argument node is "nilled"

node-name($arg as node()?) xs:QName?
Returns an expanded-QName for node kinds that can have names. For other kinds of nodes it returns the empty sequence. If $arg is the empty sequence, the empty sequence is returned.
$argThe input node

Returns the expanded QName

normalize-space($arg as xs:string?) xs:string
Returns the value of $arg with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of one or more than one whitespace character with a single space, #x20.
The whitespace characters are defined in the metasymbol S (Production 3) of [Extensible Markup Language (XML) 1.0 Recommendation (Third Edition)].
Note:
The definition of the metasymbol S (Production 3), is unchanged in [Extensible Markup Language (XML) 1.1 Recommendation].
If the value of $arg is the empty sequence, returns the zero-length string.
If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised: [err:XPDY0002].
$argThe string to normalize

Returns the normalized text

normalize-space() xs:string
Returns the calculated string value of the context item with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of one or more than one whitespace character with a single space, #x20.
The whitespace characters are defined in the metasymbol S (Production 3) of [Extensible Markup Language (XML) 1.0 Recommendation (Third Edition)].
Note:
The definition of the metasymbol S (Production 3), is unchanged in [Extensible Markup Language (XML) 1.1 Recommendation].
If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised: [err:XPDY0002].

Returns the normalized text

normalize-unicode($arg as xs:string?) xs:string
Returns the value of the context item normalized according to the nomalization form "NFC"
$argThe unicode string to normalize

Returns the normalized text

normalize-unicode($arg as xs:string?, $normalization-form as xs:string) xs:string
Returns the value of $arg normalized according to the normalization criteria for a normalization form identified by the value of $normalization-form. The effective value of the $normalization-form is computed by removing leading and trailing blanks, if present, and converting to upper case.
If the value of $arg is the empty sequence, returns the zero-length string.
See [Character Model for the World Wide Web 1.0: Normalization] for a description of the normalization forms.
- If the effective value of $normalization-form is "NFC", then the value returned by the function is the value of $arg in Unicode Normalization Form C (NFC).
- If the effective value of $normalization-form is "NFD", then the value returned by the function is the value of $arg in Unicode Normalization Form D (NFD).
- If the effective value of $normalization-form is "NFKC", then the value returned by the function is the value of $arg in Unicode Normalization Form KC (NFKC).
- If the effective value of $normalization-form is "NFKD", then the value returned by the function is the value of $arg in Unicode Normalization Form KD (NFKD).
- If the effective value of $normalization-form is "FULLY-NORMALIZED", then the value returned by the function is the value of $arg in the fully normalized form.
- If the effective value of $normalization-form is the zero-length string, no normalization is performed and $arg is returned.
Conforming implementations must support normalization form "NFC" and may support normalization forms "NFD", "NFKC", "NFKD", "FULLY-NORMALIZED". They may also support other normalization forms with implementation-defined semantics. If the effective value of the $normalization-form is other than one of the values supported by the implementation, then an error is raised [err:FOCH0003].
$argThe unicode string to normalize
$normalization-formThe normalization form

Returns the normalized text

not($arg as item()*) xs:boolean
Returns true if the effective boolean value is false, and false if the effective boolean value is true.
$arg is reduced to an effective boolean value by applying the fn:boolean() function.
$argThe input items

Returns the negated effective boolean value (ebv) of $arg

number($arg as xdt:anyAtomicType?) xs:double
Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double.
Calling the zero-argument version of the function is defined to give the same result as calling the single-argument version with the context item (.). That is, fn:number() is equivalent to fn:number(.).
If $arg is the empty sequence or if $arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]XP.
If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context item after atomization, is converted to an xs:double following the rules of 17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.
$argThe input item

Returns the numerical value

number() xs:double
Returns the value of the context item after atomization, converted to an xs:double.
If the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]XP.

Returns the numerical value

one-or-more($arg as item()*) item()+
Returns $arg if it contains one or more items. Otherwise, raises an error.
$argThe input sequence

Returns the sequence passed in by $arg if it contains one or more items.

position() xs:integer?
Returns the context position from the dynamic context. If the context item is undefined, raises an error.

Returns the context position

prefix-from-QName($arg as xs:QName?) xs:NCName?
Returns an xs:NCName representing the prefix of $arg. If $arg is the empty sequence, returns the empty sequence.
$argThe QName

Returns the prefix

QName($uri as xs:string?, $qname as xs:string) xs:QName
Returns an xs:QName with the namespace URI given in $uri. If $uri is the zero-length string or the empty sequence, it represents "no namespace"; in this case, if the value of $qname contains a colon (:), an error is raised [err:FOCA0002]. The prefix (or absence of a prefix) in $qname is retained in the returned xs:QName value. The local name in the result is taken from the local part of $qname.
If $qname does not have the correct lexical form for xs:QName an error is raised [err:FOCA0002].
Note that unlike xs:QName this function does not require a xs:string literal as the argument.
$uriThe namespace URI
$qnameThe prefix

Returns the xs:QName with the namespace URI given in $uri

remove($target as item()*, $position as xs:integer) item()*
Returns a new sequence constructed from the value of $target with the item at $position removed.
If $position is less than 1 or greater than the number of items in $target, $target is returned. Otherwise, the value returned by the function consists of all items of $target whose index is less than $position, followed by all items of $target whose index is greater than $position. If $target is the empty sequence, the empty sequence is returned.
$targetThe input sequence
$positionThe position of the value to be removed

Returns the new sequence with the item at the position specified by the value of $position removed.

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) xs:string?
The function returns the xs:string that is obtained by replacing each non-overlapping substring of $input that matches the given $pattern with an occurrence of the $replacement string.
If $input is the empty sequence, it is interpreted as the zero-length string.
If two overlapping substrings of $input both match the $pattern, then only the first one (that is, the one whose first character comes first in the $input string) is replaced.
Within the $replacement string, a variable $N may be used to refer to the substring captured by the Nth parenthesized sub-expression in the regular expression. For each match of the pattern, these variables are assigned the value of the content matched by the relevant sub-expression, and the modified replacement string is then substituted for the characters in $input that matched the pattern. $0 refers to the substring captured by the regular expression as a whole.
More specifically, the rules are as follows, where S is the number of parenthesized sub-expressions in the regular expression, and N is the decimal number formed by taking all the digits that consecutively follow the $ character:
1. If N=0, then the variable is replaced by the substring matched by the regular expression as a whole.
2. If 1<=N<=S, then the variable is replaced by the substring captured by the Nth parenthesized sub-expression. If the Nth parenthesized sub-expression was not matched, then the variable is replaced by the zero-length string.
3. If S<N<=9, then the variable is replaced by the zero-length string.
4. Otherwise (if N>S and N>9), the last digit of N is taken to be a literal character to be included "as is" in the replacement string, and the rules are reapplied using the number N formed by stripping off this last digit.
$inputThe input string
$patternThe pattern to match
$replacementThe string to replace the pattern with

Returns the altered string

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) xs:string?
The function returns the xs:string that is obtained by replacing each non-overlapping substring of $input that matches the given $pattern with an occurrence of the $replacement string.
The $flags argument is interpreted in the same manner as for the fn:matches() function.
Calling the four argument version with the $flags argument set to a zero-length string gives the same effect as using the three argument version.
If $input is the empty sequence, it is interpreted as the zero-length string.
If two overlapping substrings of $input both match the $pattern, then only the first one (that is, the one whose first character comes first in the $input string) is replaced.
Within the $replacement string, a variable $N may be used to refer to the substring captured by the Nth parenthesized sub-expression in the regular expression. For each match of the pattern, these variables are assigned the value of the content matched by the relevant sub-expression, and the modified replacement string is then substituted for the characters in $input that matched the pattern. $0 refers to the substring captured by the regular expression as a whole.
More specifically, the rules are as follows, where S is the number of parenthesized sub-expressions in the regular expression, and N is the decimal number formed by taking all the digits that consecutively follow the $ character:
1. If N=0, then the variable is replaced by the substring matched by the regular expression as a whole.
2. If 1<=N<=S, then the variable is replaced by the substring captured by the Nth parenthesized sub-expression. If the Nth parenthesized sub-expression was not matched, then the variable is replaced by the zero-length string.
3. If S<N<=9, then the variable is replaced by the zero-length string.
4. Otherwise (if N>S and N>9), the last digit of N is taken to be a literal character to be included "as is" in the replacement string, and the rules are reapplied using the number N formed by stripping off this last digit.
$inputThe input string
$patternThe pattern to match
$replacementThe string to replace the pattern with
$flagsThe flags

Returns the altered string

resolve-QName($qname as xs:string?, $element as element()) xs:QName
Returns an xs:QName value (that is, an expanded-QName) by taking an xs:string that has the lexical form of an xs:QName (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.
If $qname does not have the correct lexical form for xs:QName an error is raised [err:FOCA0002].
If $qname is the empty sequence, returns the empty sequence.
More specifically, the function searches the namespace bindings of $element for a binding whose name matches the prefix of $qname, or the zero-length string if it has no prefix, and constructs an expanded-QName whose local name is taken from the supplied $qname, and whose namespace URI is taken from the string value of the namespace binding.
If the $qname has a prefix and if there is no namespace binding for $element that matches this prefix, then an error is raised [err:FONS0004].
If the $qname has no prefix, and there is no namespace binding for $element corresponding to the default (unnamed) namespace, then the resulting expanded-QName has no namespace part.
The prefix (or absence of a prefix) in the supplied $qname argument is retained in the returned expanded-QName.
$qnameThe QName name
$elementThe element

Returns the QName of $element with lexical form $qname

resolve-uri($relative as xs:string?) xs:anyURI?
Resolves $relative against the value of the base-uri property from the static context using an algorithm such as the ones described in [RFC 2396] or [RFC 3986], and the resulting absolute URI reference is returned. An error may be raised [err:FORG0009] in the resolution process.
If $relative is an absolute URI reference, it is returned unchanged.
If $relative or $base is not a valid xs:anyURI an error is raised [err:FORG0002].
If $relative is the empty sequence, the empty sequence is returned.
$relativeThe relative URI

Returns the absolute URI

resolve-uri($relative as xs:string?, $base as xs:string) xs:anyURI?
Resolves $relative against $base using an algorithm such as the ones described in [RFC 2396] or [RFC 3986], and the resulting absolute URI reference is returned. An error may be raised [err:FORG0009] in the resolution process.
If $relative is an absolute URI reference, it is returned unchanged.
If $relative or $base is not a valid xs:anyURI an error is raised [err:FORG0002].
If $relative is the empty sequence, the empty sequence is returned.
$relativeThe relative URI
$baseThe base URI

Returns the absolute URI

reverse($arg as item()*) item()*
Reverses the order of items in a sequence. If the argument is an emptysequence, the empty sequence is returned.
$argThe sequence to reverse

Returns the reverse order sequence

root($arg as node()?) node()?
Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node.
If $arg is the empty sequence, the empty sequence is returned.
If $arg is a document node, $arg is returned.
The behavior of the zero argument version of the function is exactly the same as if the context item had been passed in $arg.
$argThe input node

Returns the root node of the tree to which $arg belongs

root() node()
Returns the root of the tree to which the context item belongs.

Returns the root node of the tree to which the context node belongs

round($arg as numeric?) numeric
Returns the number with no fractional part that is closest to the argument $arg. If there are two such numbers, then the one that is closest to positive infinity is returned. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
For xs:float and xs:double arguments, if the argument is positive infinity, then positive infinity is returned. If the argument is negative infinity, then negative infinity is returned. If the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero, but greater than or equal to -0.5, then negative zero is returned. In the cases where positive zero or negative zero is returned, negative zero or positive zero may be returned as [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero.
$argThe input number

Returns the rounded value

round-half-to-even($arg as numeric?) numeric
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus 0. If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
If the type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
The three argument version of the function with $precision = 0 produces the same result as the two argument version.
For arguments of type xs:float and xs:double, if the argument is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument. In all other cases, the argument is cast to xs:decimal, the function is applied to this xs:decimal value, and the resulting xs:decimal is cast back to xs:float or xs:double as appropriate to form the function result. If the resulting xs:decimal value is zero, then positive or negative zero is returned according to the sign of the original argument.
Note that the process of casting to xs:decimal may result in an error [err:FOCA0001].
If $arg is of type xs:float or xs:double, rounding occurs on the value of the mantissa computed with exponent = 0.
$argThe input number

Returns the rounded value

round-half-to-even($arg as numeric?, $precision as numeric?) numeric
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision. If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
If the type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
The three argument version of the function with $precision = 0 produces the same result as the two argument version.
For arguments of type xs:float and xs:double, if the argument is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument. In all other cases, the argument is cast to xs:decimal, the function is applied to this xs:decimal value, and the resulting xs:decimal is cast back to xs:float or xs:double as appropriate to form the function result. If the resulting xs:decimal value is zero, then positive or negative zero is returned according to the sign of the original argument.
Note that the process of casting to xs:decimal may result in an error [err:FOCA0001].
If $arg is of type xs:float or xs:double, rounding occurs on the value of the mantissa computed with exponent = 0.
$argThe input number
$precisionThe precision factor

Returns the rounded value

seconds-from-dateTime($date-time as xs:dateTime?) xs:decimal?
Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of $date-time. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.
$date-timeThe date-time as xs:dateTime

Returns the seconds component from $date-time

seconds-from-duration($duration as xdt:dayTimeDuration?) xs:decimal?
Returns an xs:decimal representing the seconds component in the canonical lexical representation of the value of $duration. The result may be negative
$durationThe duration as xs:dayTimeDuration

Returns the seconds component of $duration

seconds-from-time($time as xs:time?) xs:decimal?
Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of $date. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.
$timeThe time as xs:time

Returns the seconds component from $time

starts-with($source as xs:string?, $prefix as xs:string?) xs:boolean?
Returns an xs:boolean indicating whether or not the value of $source starts with a sequence of collation units that provides a minimal match to the collation units of $prefix according to the collation that is used.
Note:
"Minimal match" is defined in [Unicode Collation Algorithm].
If the value of $source or $prefix is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.
If the value of $prefix is the zero-length string, then the function returns true. If the value of $source is the zero-length string and the value of $prefix is not the zero-length string, then the function returns false.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. If the specified collation does not support collation units an error may be raised [err:FOCH0004].
$sourceThe source string
$prefixThe string to determine if is a prefix of $source

Returns true if $prefix is a prefix of the string $source

starts-with($source as xs:string?, $prefix as xs:string?, $collation-uri as xs:string) xs:boolean?
Returns an xs:boolean indicating whether or not the value of $source starts with a sequence of collation units that provides a minimal match to the collation units of $prefix according to the collation that is used.
Note:
"Minimal match" is defined in [Unicode Collation Algorithm].
If the value of $source or $prefix is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.
If the value of $prefix is the zero-length string, then the function returns true. If the value of $source is the zero-length string and the value of $prefix is not the zero-length string, then the function returns false.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. If the specified collation does not support collation units an error may be raised [err:FOCH0004]. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$sourceThe source string
$prefixThe string to determine if is a prefix of $source
$collation-uriThe collation URI

Returns true if $prefix is a prefix of the string $source

static-base-uri() xs:anyURI?
Returns the value of the base URI property from the static context. If the base-uri property is undefined, the empty sequence is returned.

Returns the base URI from the static context

string($arg as item()?) xs:string
Returns the value of $arg as xs:string. If the value of $arg is the empty sequence, the zero-length string is returned. If the context item of $arg is undefined, an error is raised.
$argThe sequence to get the vaule of as an xs:string

Returns the value of $arg as an xs:string

string() xs:string
Returns the value of the context item as xs:string. If the context item is undefined, an error is raised.

Returns the value of the context item as an xs:string

string-join($arg as xs:string*, $separator as xs:string) xs:string
Returns a xs:string created by concatenating the members of the $arg sequence using $separator as a separator. If the value of the separator is the zero-length string, then the members of the sequence are concatenated without a separator.
$argThe sequence to be joined to form the string
$separatorThe separator to be placed in the string between the items of $arg

Returns the joined string

string-length($arg as xs:string?) xs:integer?
Returns an xs:integer equal to the length in characters of the value of $arg.
If the value of $arg is the empty sequence, the xs:integer 0 is returned.
If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised
$argThe input string

Returns the length in characters

string-length() xs:integer?
Returns an xs:integer equal to the length in characters of the value of the context item.
If the context item is undefined an error is raised.

Returns the length in characters

string-pad($arg as xs:string?, $count as xs:integer) xs:string?
Returns an xs:string consisting of a number copies of $arg concatenated together without any separators. The number of copies is specified by $count.
$argThe string to be duplicated
$countThe number of copies of $arg to be returned

Returns the duplicated string

string-to-codepoints($arg as xs:string?) xs:integer*
Returns the sequence of unicode code points that constitute an xs:string. If $arg is a zero-length string or the empty sequence, the empty sequence is returned.
$argThe input string

Returns the sequence of code points

subsequence($source as item()*, $starting-at as xs:double) item()*
Returns a subsequence of the items in $source-sequence, items starting at the position, $starting-at, up to the end of the sequence are included.
$sourceThe source sequence
$starting-atThe starting position in the $source

Returns the subsequence

subsequence($source as item()*, $starting-at as xs:double, $length as xs:double) item()*
Returns a subsequence of the items in $source, starting at the position, $starting-at, including the number of items indicated by $length.
$sourceThe source sequence
$starting-atThe starting position in the $source
$lengthThe length of the subsequence

Returns the subsequence

substring($source as xs:string?, $starting-at as xs:double) xs:string?
Returns the portion of the value of $source beginning at the position indicated by the value of $starting-at and continuing to the end of $source. The characters returned do not extend beyond the end of $source. If $starting-at is zero or negative, only those characters in positions greater than zero are returned.If the value of $source is the empty sequence, the zero-length string is returned.
$sourceThe source string
$starting-atThe starting position

Returns the substring

substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) xs:string?
Returns the portion of the value of $source beginning at the position indicated by the value of $starting-at and continuing for the number of characters indicated by the value of $length. The characters returned do not extend beyond the end of $source. If $starting-at is zero or negative, only those characters in positions greater than zero are returned. If the value of $source is the empty sequence, the zero-length string is returned.
$sourceThe source string
$starting-atThe starting position
$lengthThe number of characters in the substring

Returns the substring

substring-after($source as xs:string?, $search as xs:string?) xs:string?
Returns the substring of the value of $source that follows the first occurrence of a sequence of the value of $search. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned.
$sourceThe input string
$searchThe search string

Returns the substring after $search

substring-after($source as xs:string?, $search as xs:string?, $collation-uri as xs:string) xs:string?
Returns the substring of the value of $source that follows the first occurrence of a sequence of the value of $search in the collation $collation-uri. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$sourceThe input string
$searchThe search string
$collation-uriThe collation URI

Returns the substring after $search

substring-before($source as xs:string?, $search as xs:string?) xs:string?
Returns the substring of the value of $source that precedes the first occurrence of a sequence of the value of $search. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned.
$sourceThe input string
$searchThe search string

Returns the substring before $search

substring-before($source as xs:string?, $search as xs:string?, $collation-uri as xs:string) xs:string?
Returns the substring of the value of $source that precedes the first occurrence of a sequence of the value of $search in the collation $collation-uri. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned. The third argument $collation-uri is relative so you only need to specify the last part of a valid full collation-uri, e.g. '?lang=sv-SE', 'lang=sv-SE;strength=primary;decomposition=standard' or 'swedish'.
$sourceThe input string
$searchThe search string
$collation-uriThe collation URI

Returns the substring before $search

sum($arg as xdt:anyAtomicType*) xdt:anyAtomicType
Returns a value obtained by adding together the values in $arg. If $arg is the the empty sequence the xs:double value 0.0e0 is returned.
$argThe sequence of numbers to be summed up

Returns the sum of all numbers in $arg

sum($arg as xdt:anyAtomicType*, $default as xdt:anyAtomicType?) xdt:anyAtomicType
Returns a value obtained by adding together the values in $arg. If $arg is the the empty sequence then $default is returned.
$argThe sequence of numbers to be summed up
$defaultThe default value if $arg computes to the empty sequence

Returns the sum of all numbers in $arg

timezone-from-date($date as xs:date?) xdt:dayTimeDuration?
Returns the timezone component of $date if any. If $date has a timezone component, then the result is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.If $date is the empty sequence, returns the empty sequence.
$dateThe date as xs:date

Returns the timezone component from $date

timezone-from-dateTime($date-time as xs:dateTime?) xdt:dayTimeDuration?
Returns the timezone component of $date-time if any. If $date-time has a timezone component, then the result is an xdt:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.
$date-timeThe date-time as xs:dateTime

Returns the timezone component from $date-time

timezone-from-time($time as xs:time?) xdt:dayTimeDuration?
Returns the timezone component of $time if any. If $time has a timezone component, then the result is an xdt:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.
$timeThe time as xs:time

Returns the timezone component from $time

tokenize($input as xs:string?, $pattern as xs:string) xs:string+
Breaks the input string $input into a sequence of strings, treating any substring that matches pattern $pattern as a separator. The separators themselves are not returned.
$inputThe input string
$patternThe tokenization pattern

Returns the token sequence

tokenize($input as xs:string?, $pattern as xs:string, $flags as xs:string) xs:string+
Breaks the input string $input into a sequence of strings, treating any substring that matches pattern $pattern as a separator using $flags, see http://www.w3.org/TR/xpath-functions/#flags. The separators themselves are not returned.
$inputThe input string
$patternThe tokenization pattern
$flagsThe flags

Returns the token sequence

trace($value as item()*, $label as xs:string) item()*
This function is intended to be used in debugging queries by providing a trace of their execution. The input $value is returned, unchanged, as the result of the function. In addition, the inputs $value, converted to an xs:string, and $label is directed to a trace data set in the eXist log files.
$valueThe value
$labelThe label in the log file

Returns the labelled $value in the log

translate($arg as xs:string?, $map as xs:string, $trans as xs:string) xs:string
Returns the value of $arg modified so that every character in the value of $arg that occurs at some position N in the value of $map has been replaced by the character that occurs at position N in the value of $trans.
If the value of $arg is the empty sequence, the zero-length string is returned.
Every character in the value of $arg that does not appear in the value of $map is unchanged.
Every character in the value of $arg that appears at some position M in the value of $map, where the value of $trans is less than M characters in length, is omitted from the returned value. If $map is the zero-length string $arg is returned.
If a character occurs more than once in $map, then the first occurrence determines the replacement character. If $trans is longer than $map, the excess characters are ignored.
i.e. fn:translate("bar","abc","ABC") returns "BAr"
$argThe string to be translated
$mapThe map string
$transThe translation string

Returns the translated string

true() xs:boolean
Always returns the boolean value true

Returns true

unordered($arg as item()*) item()*
Takes a sequence $arg as input and returns an arbitrary implementation dependent permutation of it. Currently, this has no effect in eXist, but it might be used for future optimizations.
$argThe input sequence

Returns the input sequence in an arbitrary implementation dependent permutation

upper-case($arg as xs:string?) xs:string
Returns the value of $arg after translating every character to its upper-case correspondent as defined in the appropriate case mappings section in the Unicode standard. For versions of Unicode beginning with the 2.1.8 update, only locale-insensitive case mappings should be applied. Beginning with version 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default case operations, which are full case mappings in the absence of tailoring for particular languages and environments. Every lower-case character that does not have an upper-case correspondent, as well as every upper-case character, is included in the returned value in its original form.
$argThe text to be converted to all upper-case characters

Returns the resulting upper-case text

xcollection($collection-uris as xs:string+, ...) node()*
Returns the document nodes in the collections $collection-uris non-recursively, i.e. does not include document nodes found in sub-collections.
C.f. fn:collection(). Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$collection-urisThe collection URIs

Returns the document nodes from the specified collections excluding sub-collections

Deprecated: This function is eXist-specific and deprecated. It should not be in the standard functions namespace. Please use http://exist-db.org/xquery/xmldb:xcollection() instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

year-from-date($date as xs:date?) xs:integer?
Returns an xs:integer representing the year in the localized value of $date. The value may be negative.
$dateThe date as xs:date

Returns the year component from $date

year-from-dateTime($date-time as xs:dateTime?) xs:integer?
Returns an xs:integer representing the year in the localized value of $date-time. The value may be negative.
$date-timeThe date-time as xs:dateTime

Returns the year component from $date-time

years-from-duration($duration as xdt:yearMonthDuration?) xs:integer?
Returns an xs:integer representing the years component in the canonical lexical representation of the value of $duration. The result may be negative.
$durationThe duration as xs:yearMonthDuration

Returns the years component of $duration

zero-or-one($arg as item()*) item()?
Returns the argument sequence $arg if it contains zero or one items. Otherwise, raises an error.
$argThe sequence to be tested for cardinality

Returns the input sequence if it contains zero or one items.
Return to list of all modules