Available XQuery Functions

A module with the XQuery/XPath Core Library Functions (http://www.w3.org/2005/xpath-functions)
QName
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. Parameters: $uri : The namespace URI $qname : The prefix Returns the xs:QName with the namespace URI given in $uri
abs
abs($number as numeric?) numeric
Returns the absolute value of the argument $number. If the argument is negative returns -$number otherwise returns $number. Parameters: $number : The number Returns the absolute value of the argument
adjust-date-to-timezone
adjust-date-to-timezone($date as xs:date?) xs:date?
Adjusts the xs:date value $date to the implicit timezone of the current locale. Parameters: $date : The 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. Parameters: $date : The date $duration : The duration Returns the adjusted date
adjust-dateTime-to-timezone
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. Parameters: $date-time : The 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. Parameters: $date-time : The date-time $duration : The duration Returns the adjusted date-time
adjust-time-to-timezone
adjust-time-to-timezone($time as xs:time?) xs:time?
Adjusts the xs:time value $time to the implicit timezone of the current locale. Parameters: $time : The 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. Parameters: $time : The time $duration : The duration Returns the adjusted time
avg
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. Parameters: $values : The values Returns the average of the values in the input sequence
base-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
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. Parameters: $uri : The URI Returns the base URI from $uri
boolean
boolean($items as item()*) xs:boolean
Computes the xs:boolean value of the sequence $items. Parameters: $items : The items Returns the boolean value, ebv, of the items
ceiling
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. Parameters: $number : The number Returns the non-fractional number not less than $number
codepoint-equal
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. Parameters: $string-1 : The first string $string-2 : The second string Returns true() if the codepoints are equal, false() otherwise
codepoints-to-string
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 Parameters: $codepoints : The codepoints as a sequence of xs:integer values Returns the string constructed from the codepoints if valid
collection
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. Parameters: $collection-uris : The collection-uris for which to include the documents Returns the document nodes contained in or under the given collections
compare
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. Parameters: $string-1 : The first string $string-2 : The 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'. Parameters: $string-1 : The first string $string-2 : The second string $collation-uri : The 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
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. Parameters: $atomizable-values : The atomizable values Returns the concatenated values
contains
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. Parameters: $source-string : The source-string $substring : The 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'. Parameters: $source-string : The source-string $substring : The substring $collation-uri : The collation URI Returns true() if $source-string contains $substring, false() otherwise
count
count($items as item()*) xs:integer
Returns the number of items in the argument sequence, $items. Parameters: $items : The items Returns the number of items in the argument sequence
current-date
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
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
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
data($items as item()*) xdt:anyAtomicType*
Returns the sequence of atomic values from the items in $items. Parameters: $items : The items Returns the atomic values of the items in $items
dateTime
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. Parameters: $date : The date as xs:date $time : The time as xs:time Returns the combined date and time as xs:dateTime
day-from-date
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. Parameters: $date : The date as xs:date Returns the day component from $date
day-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the day component from $date-time
days-from-duration
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. Parameters: $duration : The duration as xs:dayTimeDuration Returns the days component of $duration
deep-equal
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(). Parameters: $items-1 : The first item sequence $items-2 : The 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'. Parameters: $items-1 : The first item sequence $items-2 : The second item sequence $collation-uri : The collation URI Returns true() if the sequences are deep-equal, false() otherwise
default-collation
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
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. Parameters: $atomic-values : The 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. Parameters: $atomic-values : The atomic values $collation-uri : The collation URI Returns the distinct values sequence
doc
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. Parameters: $document-uri : The document URI Returns the document node of $document-uri
doc-available
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. Parameters: $document-uri : The document URI Returns true() if the document is available, false() otherwise
doctype
doctype($doctype as xs:string+) node()*
Returns the document nodes of the documents based on the DOCTYPE. Parameters: $doctype : one or more DOCTYPE names Returns the document nodes matching the DOCTYPE names
document
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. Parameters: $document-uris : The document URIs Returns the documents
document-uri
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. Parameters: $document-node : The document node Returns the document URI of $document-node
empty
empty($items as item()*) xs:boolean
Returns true() if the value of $items is the empty sequence, false() otherwise. Parameters: $items : The item sequence Returns true() if the empty sequence, false() otherwise
encode-for-uri
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. Parameters: $uri-part : The URI part to encode Returns the URI part with reserved characters percent encoded
ends-with
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. Parameters: $source-string : The source-string $suffix : The 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'. Parameters: $source-string : The source-string $suffix : The suffix $collation-uri : The collation URI Returns true() if $suffix is suffix of $source-string, false() otherwise
error
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'.
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'. Parameters: $qname : The 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. Parameters: $qname : The qname $message : The 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. Parameters: $qname : The qname $message : The message $error-object : The error object
escape-html-uri
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. Parameters: $html-uri : The html URI Returns all nonprintable ASCII characters in $html-uri encoded by escape sequences
escape-uri
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. Parameters: $uri : The URI $escape-reserved : The escaped-reserved Returns the identified characters in $uri encoded with escape sequences
exactly-one
exactly-one($items as item()*) item()
Returns the argument sequence, $items, if it contains exactly one item. Otherwise, raises an error. Parameters: $items : The item sequence Returns the sole item in $items if it contains exactly one item. Otherwise, an error is raised.
exists
exists($items as item()*) xs:boolean
Returns true if the argument $items is not the empty sequence, false otherwise. Parameters: $items : The item sequence Returns true() if not the empty-sequence, false() otherwise
false
false() xs:boolean
Always returns the boolean value false Returns false
floor
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. Parameters: $number : The number Returns the largets number without fraction part not greater than the value of $number
hours-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the hours component from $date-time
hours-from-duration
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. Parameters: $duration : The duration as xs:dayTimeDuration Returns the hours component of $duration
hours-from-time
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. Parameters: $time : The time as xs:time Returns the hours component from $time
id
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. Parameters: $idrefs : The 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. Parameters: $idrefs : The IDREF sequence $node-in-document : The node in document Returns the elements with IDs matching IDREFs from $idrefs in the same document as $node-in-document
idref
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. Parameters: $ids : The 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. Parameters: $ids : The ID sequence $node-in-document : The node in document Returns the elements with matching IDREF values from IDs in $ids in the same document as $node-in-document
implicit-timezone
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
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. Parameters: $element : The element Returns the prefixes
index-of
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. Parameters: $source : The source sequence $search : The 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'. Parameters: $source : The source sequence $search : The search component $collation-uri : The collation URI Returns the sequence of positive integers giving the positions within the sequence
insert-before
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. Parameters: $target : The target $position : The position to insert before $inserts : The data to insert Returns the new sequence
iri-to-uri
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". Parameters: $iri : The IRI Returns the URI
item-at
item-at($source as item()*, $index as xs:integer) item()?
Returns the item in $source that is located at the position specified by $index. Parameters: $source : The source sequence $index : The index of the item in the source sequence to return Returns the item
lang
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. Parameters: $lang : The 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. Parameters: $lang : The language code $node : The node Returns true if the language code matches, false otherwise
last
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
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($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. Parameters: $arg : The node to retrieve the local name from Returns the local name
local-name-from-QName
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. Parameters: $arg : The QName Returns the local name
lower-case
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. Parameters: $arg : The text to be converted to all lower-case characters Returns the resulting lower-case text
match-all
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. Parameters: $nodes : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index Returns the sequence of all of the matching nodes
match-any
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. Parameters: $nodes : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index Returns the sequence of all of the matching nodes
matches
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. Parameters: $input : The input string $pattern : The 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. Parameters: $input : The input string $pattern : The pattern $flags : The flags Returns true if the pattern is a match, false otherwise
max
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. Parameters: $arg : The 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. Parameters: $arg : The input sequence $collation-uri : The collation URI Returns the max value
min
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. Parameters: $arg : The 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. Parameters: $arg : The input sequence $collation-uri : The collation URI Returns the minimum value
minutes-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the minutes component from $date-time
minutes-from-duration
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. Parameters: $duration : The duration as xs:dayTimeDuration Returns the minutes component of $duration
minutes-from-time
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. Parameters: $time : The time as xs:time Returns the minutes component from $time
month-from-date
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. Parameters: $date : The date as xs:date Returns the month component from $date
month-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the month component from $date-time
months-from-duration
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. Parameters: $duration : The duration as xs:yearMonthDuration Returns the months component of $duration
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
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)). Parameters: $arg : The input node Returns the name
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($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. Parameters: $arg : The input node Returns the namespace URI
namespace-uri-for-prefix
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. Parameters: $prefix : The namespace prefix $element : The element Returns the namespace URI
namespace-uri-from-QName
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. Parameters: $arg : The QName Returns the namespace URI
nilled
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. Parameters: $arg : The input node Returns true if the argument node is "nilled"
node-name
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. Parameters: $arg : The input node Returns the expanded QName
normalize-space
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-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]. Parameters: $arg : The string to normalize Returns the normalized text
normalize-unicode
normalize-unicode($arg as xs:string?) xs:string
Returns the value of the context item normalized according to the nomalization form "NFC" Parameters: $arg : The 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]. Parameters: $arg : The unicode string to normalize $normalization-form : The normalization form Returns the normalized text
not
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. Parameters: $arg : The input items Returns the negated effective boolean value (ebv) of $arg
number
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
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. Parameters: $arg : The input item Returns the numerical value
one-or-more
one-or-more($arg as item()*) item()+
Returns $arg if it contains one or more items. Otherwise, raises an error. Parameters: $arg : The input sequence Returns the sequence passed in by $arg if it contains one or more items.
position
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
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. Parameters: $arg : The QName Returns the prefix
remove
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. Parameters: $target : The input sequence $position : The 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
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. Parameters: $input : The input string $pattern : The pattern to match $replacement : The 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. Parameters: $input : The input string $pattern : The pattern to match $replacement : The string to replace the pattern with $flags : The flags Returns the altered string
resolve-QName
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. Parameters: $qname : The QName name $element : The element Returns the QName of $element with lexical form $qname
resolve-uri
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. Parameters: $relative : The 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. Parameters: $relative : The relative URI $base : The base URI Returns the absolute URI
reverse
reverse($arg as item()*) item()*
Reverses the order of items in a sequence. If the argument is an emptysequence, the empty sequence is returned. Parameters: $arg : The sequence to reverse Returns the reverse order sequence
root
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
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. Parameters: $arg : The input node Returns the root node of the tree to which $arg belongs
round
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. Parameters: $arg : The input number Returns the rounded value
round-half-to-even
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. Parameters: $arg : The 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. Parameters: $arg : The input number $precision : The precision factor Returns the rounded value
seconds-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the seconds component from $date-time
seconds-from-duration
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 Parameters: $duration : The duration as xs:dayTimeDuration Returns the seconds component of $duration
seconds-from-time
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. Parameters: $time : The time as xs:time Returns the seconds component from $time
starts-with
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]. Parameters: $source : The source string $prefix : The 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'. Parameters: $source : The source string $prefix : The string to determine if is a prefix of $source $collation-uri : The collation URI Returns true if $prefix is a prefix of the string $source
static-base-uri
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
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($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. Parameters: $arg : The sequence to get the vaule of as an xs:string Returns the value of $arg as an xs:string
string-join
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. Parameters: $arg : The sequence to be joined to form the string $separator : The separator to be placed in the string between the items of $arg Returns the joined string
string-length
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-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 Parameters: $arg : The input string Returns the length in characters
string-pad
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. Parameters: $arg : The string to be duplicated $count : The number of copies of $arg to be returned Returns the duplicated string
string-to-codepoints
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. Parameters: $arg : The input string Returns the sequence of code points
subsequence
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. Parameters: $source : The source sequence $starting-at : The 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. Parameters: $source : The source sequence $starting-at : The starting position in the $source $length : The length of the subsequence Returns the subsequence
substring
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. Parameters: $source : The source string $starting-at : The 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. Parameters: $source : The source string $starting-at : The starting position $length : The number of characters in the substring Returns the substring
substring-after
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. Parameters: $source : The input string $search : The 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'. Parameters: $source : The input string $search : The search string $collation-uri : The collation URI Returns the substring after $search
substring-before
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. Parameters: $source : The input string $search : The 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'. Parameters: $source : The input string $search : The search string $collation-uri : The collation URI Returns the substring before $search
sum
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. Parameters: $arg : The 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. Parameters: $arg : The sequence of numbers to be summed up $default : The default value if $arg computes to the empty sequence Returns the sum of all numbers in $arg
timezone-from-date
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. Parameters: $date : The date as xs:date Returns the timezone component from $date
timezone-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the timezone component from $date-time
timezone-from-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. Parameters: $time : The time as xs:time Returns the timezone component from $time
tokenize
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. Parameters: $input : The input string $pattern : The 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. Parameters: $input : The input string $pattern : The tokenization pattern $flags : The flags Returns the token sequence
trace
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. Parameters: $value : The value $label : The label in the log file Returns the labelled $value in the log
translate
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" Parameters: $arg : The string to be translated $map : The map string $trans : The translation string Returns the translated string
true
true() xs:boolean
Always returns the boolean value true Returns true
unordered
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. Parameters: $arg : The input sequence Returns the input sequence in an arbitrary implementation dependent permutation
upper-case
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. Parameters: $arg : The text to be converted to all upper-case characters Returns the resulting upper-case text
xcollection
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. Parameters: $collection-uris : The collection URIs Returns the document nodes from the specified collections excluding sub-collections
year-from-date
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. Parameters: $date : The date as xs:date Returns the year component from $date
year-from-dateTime
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. Parameters: $date-time : The date-time as xs:dateTime Returns the year component from $date-time
years-from-duration
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. Parameters: $duration : The duration as xs:yearMonthDuration Returns the years component of $duration
zero-or-one
zero-or-one($arg as item()*) item()?
Returns the argument sequence $arg if it contains zero or one items. Otherwise, raises an error. Parameters: $arg : The sequence to be tested for cardinality Returns the input sequence if it contains zero or one items.
A module for performing XSL-FO transformations (http://exist-db.org/xquery/xslfo)
xslfo:render
xslfo:render($document as node(), $mime-type as xs:string, $parameters as node()?) xs:base64Binary?
Renders a given XSL-FO document. Returns an xs:base64binary of the result. Parameters are specified with the structure: <parameters><param name="param-name1" value="param-value1"/></parameters>. Recognised rendering parameters are: author, title, keywords and dpi. Parameters: $document : XSL-FO document $mime-type : $parameters : parameters for the transform Returns result
xslfo:render($document as node(), $mime-type as xs:string, $parameters as node()?, $config-file as node()?) xs:base64Binary?
Renders a given XSL-FO document. Returns an xs:base64binary of the result. Parameters are specified with the structure: <parameters><param name="param-name1" value="param-value1"/></parameters>. Recognised rendering parameters are: author, title, keywords and dpi. Parameters: $document : XSL-FO document $mime-type : $parameters : parameters for the transform $config-file : Apache FOP Configuration file Returns result
XQDoc integration module. (http://exist-db.org/xquery/xqdoc)
xqdm:scan
xqdm:scan($uri as xs:anyURI) node()*
Scan and extract function documentation from an external XQuery function module according to theXQDoc specification. The single argument URI may either point to an XQuery module stored in the db (URI starts with xmldb:exist:...) or a module in the file system. A file system module is searched in the same way as if it were loaded through an "import module" statement. Static mappings defined in conf.xml are searched first. Parameters: $uri : The URI from which to load the function module Returns the function docs.
xqdm:scan($data as xs:base64Binary, $name as xs:string) node()*
Scan and extract function documentation from an external XQuery function module according to the XQDoc specification. The two parameter version of the function expects to get the source code of the module in the first argument and a name for the module in the second. Parameters: $data : The base64 encoded source data of the module $name : The name of the module Returns the function docs.
A module for determining differences in XML documents. (http://exist-db.org/xquery/xmldiff)
xmldiff:compare
xmldiff:compare($node-set-1 as node()*, $node-set-2 as node()*) xs:boolean?
Returns true() if the two node sets $node-set-1 and $node-set-2 are equal, otherwise false() Parameters: $node-set-1 : the first node set $node-set-2 : the second node set Returns true() if the two node sets $node-set-1 and $node-set-2 are equal, otherwise false()
A module for database manipulation functions. (http://exist-db.org/xquery/xmldb)
xmldb:authenticate
xmldb:authenticate($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?) xs:boolean
Check if the user, $user-id, can authenticate against the database collection $collection-uri. The function simply tries to read the collection $collection-uri, using the credentials $user-id and $password. It returns true if the authentication succeeds, false otherwise. Parameters: $collection-uri : The collection URI $user-id : The user-id $password : The password Returns true() on successful authentication, false() otherwise
xmldb:change-user
xmldb:change-user($user-id as xs:string, $password as xs:string?, $groups as xs:string*, $home-collection as xs:string?) empty()
Change properties of an existing database user. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships, $home-collection is the home collection. The username, $user-id, is mandatory. Non-empty values for the other parameters are optional, where if empty the existing value is used. Parameters: $user-id : The user-id $password : The password $groups : The groups the user is member of $home-collection : The user's home collection
xmldb:chmod-collection
xmldb:chmod-collection($collection as xs:string, $mode as xs:integer) empty()
Sets the mode of collection $collection. $mode is the mode as xs:integer. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience. Parameters: $collection : The collection path $mode : The mode as xs:integer
xmldb:chmod-resource
xmldb:chmod-resource($collection as xs:string, $resource as xs:string, $mode as xs:integer) empty()
Sets the mode of the resource $resource in collection $collection, $mode is the mode as xs:integer. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience. Parameters: $collection : The collection $resource : The resource $mode : The mode as xs:integer
xmldb:collection-available
xmldb:collection-available($collection-path as xs:string) xs:boolean
Returns true() if the collection $collection exists and is available, otherwise false(). Parameters: $collection-path : The collection path Returns true() if the collection exists and is available, false() otherwise
xmldb:collection-exists
xmldb:collection-exists($collection-path as xs:string, ...) xs:boolean
Returns true() if the collection $collection exists and is available, otherwise false(). Parameters: $collection-path : The collection path Returns true() if the collection exists and is available, false() otherwise
xmldb:copy
xmldb:copy($source-collection-uri as xs:string, $target-collection-uri as xs:string) empty()
Copy the collection $source-collection-uri to the collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $source-collection-uri : The source collection URI $target-collection-uri : The target collection URI
xmldb:copy($source-collection-uri as xs:string, $target-collection-uri as xs:string, $resource as xs:string) empty()
Copy the resource $resource in $source-collection-uri to collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $source-collection-uri : The source collection URI $target-collection-uri : the target collection URI $resource : the resource to copy
xmldb:create-collection
xmldb:create-collection($target-collection-uri as xs:string, $new-collection as xs:string) xs:string?
Create a new collection with name $new-collection as a child of $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.Returns the path to the new collection if successfully created, otherwise the empty sequence. Parameters: $target-collection-uri : The target collection URI $new-collection : The name of the new collection to create Returns the path to the new collection if successfully created, otherwise the empty sequence
xmldb:create-user
xmldb:create-user($user-id as xs:string, $password as xs:string, $groups as xs:string+, $home-collection-uri as xs:string?) empty()
Create a new user, $user-id, in the database. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships. The first group in the sequence is the primary group.$home-collection-uri is the home collection URI.Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $user-id : The user-id $password : The password $groups : The group memberships $home-collection-uri : The home collection URI
xmldb:created
xmldb:created($collection-uri as xs:string) xs:dateTime
Returns the creation date of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI Returns the creation date
xmldb:created($collection-uri as xs:string, $resource as xs:string) xs:dateTime
Returns the creation date of the resource $resource in $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the creation date
xmldb:decode
xmldb:decode($string as xs:string) xs:string
Decodes the string $string such that any percent encoded octets will be translated to their decoded UTF-8 representation. Parameters: $string : The input string Returns the decoded string
xmldb:decode-uri
xmldb:decode-uri($uri as xs:anyURI) xs:string
Decodes the URI $uri such that any percent encoded octets will be translated to their decoded UTF-8 representation. Parameters: $uri : The URI Returns the decoded $uri as xs:string
xmldb:defragment
xmldb:defragment($nodes as node()+) empty()
Start a defragmentation run on each document which has a node in $nodes. Fragmentation may occur if nodes are inserted into a document using XQuery update extensions. Please note that defragmenting a document changes its internal structure, so any references to this document will become invalid, in particular, variables pointing to some nodes in the document. Parameters: $nodes : The sequence of nodes from the documents to defragment
xmldb:defragment($nodes as node()+, $integer as xs:integer) empty()
Start a defragmentation run on each document which has a node in $nodes. Fragmentation may occur if nodes are inserted into a document using XQuery update extensions. The second argument specifies the minimum number of fragmented pages which should be in a document before it is considered for defragmentation. Please note that defragmenting a document changes its internal structure, so any references to this document will become invalid, in particular, variables pointing to some nodes in the document. Parameters: $nodes : The sequence of nodes from the documents to defragment $integer : The minimum number of fragmented pages required before defragmenting
xmldb:delete-user
xmldb:delete-user($user-id as xs:string) empty()
Deletes an existing user, $user-id, in the database. This does not delete the user's home collection. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role, and not being the owner of the currently running XQuery. You cannot delete the owner of the currently running XQuery. Parameters: $user-id : The user-id to delete
xmldb:document
xmldb:document($document-uris as xs:string+, ...) node()*
Returns the documents $document-uris in the input sequence. 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. Parameters: $document-uris : The document URIs Returns the documents
xmldb:document-has-lock
xmldb:document-has-lock($collection-uri as xs:string, $resource as xs:string) xs:string?
Returns the user-id of the user that holds a write lock on the resource $resource in the collection $collection-uri. If no lock is in place, the empty sequence is returned. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the user id of the lock owner, otherwise if not locked the empty sequence
xmldb:encode
xmldb:encode($string as xs:string) xs:string
Encodes the string $string such that it will be a valid collection or resource path. Provides similar functionality to java's URLEncoder.encode() function, with some enhancements. Parameters: $string : The input string Returns the URL encoded string
xmldb:encode-uri
xmldb:encode-uri($string as xs:string) xs:anyURI
Encodes the string $string such that it will be a valid collection or resource path. Provides similar functionality to java's URLEncoder.encode() function, with some enhancements. Returns an xs:anyURI object representing a valid XmldbURI Parameters: $string : The input string Returns the XmldbURI encoded from $string
xmldb:exists-user
xmldb:exists-user($user-id as xs:string) xs:boolean
Returns true if the user $user-id exists. Parameters: $user-id : The user-id Returns true() if the user exists, false() otherwise
xmldb:get-child-collections
xmldb:get-child-collections($collection-uri as xs:string) xs:string*
Returns the names of the child collections in the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI Returns the sequence of child collection names
xmldb:get-child-resources
xmldb:get-child-resources($collection-uri as item()) xs:string*
Returns the names of the child resources in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI Returns the sequence of resource names
xmldb:get-current-user
xmldb:get-current-user() xs:string
Returns the user-id of the current user from the xquery context. Returns the user-id of the current user
xmldb:get-group
xmldb:get-group($collection-uri as xs:string) xs:string?
Returns the owner group of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI Returns the owner group
xmldb:get-group($collection-uri as xs:string, $resource as xs:string) xs:string?
Returns the owner group of the resource $resource in the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the owner group
xmldb:get-mime-type
xmldb:get-mime-type($resource-uri as xs:anyURI) xs:string?
Returns the MIME type if available of the resource $resource-uri, otherwise the empty sequence. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI. Parameters: $resource-uri : The resource URI Returns the mime-type if available, otherwise the empty sequence
xmldb:get-owner
xmldb:get-owner($collection-uri as item()) xs:string?
Returns the owner user-id of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI Returns the user-id
xmldb:get-owner($collection-uri as item(), $resource as xs:string) xs:string?
Returns the owner user-id of the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the user-id
xmldb:get-permissions
xmldb:get-permissions($collection-uri as xs:string) xs:int?
Returns the permissions assigned to the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection-uri Returns the collection permissions
xmldb:get-permissions($collection-uri as xs:string, $resource as xs:string) xs:int?
Returns the permissions assigned to the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection-uri $resource : The resource Returns the resource permissions
xmldb:get-user-groups
xmldb:get-user-groups($user-id as xs:string) xs:string+
Returns the sequence of groups the user $user-id is a member of. Parameters: $user-id : The user-id Returns the group memberships
xmldb:get-user-home
xmldb:get-user-home($user-id as xs:string) xs:anyURI?
Returns the user's home collection URI or the empty sequence if no home collection is assigned to the user $user-id. Parameters: $user-id : The user-id Returns the home collection URI of user $user-id if one is assigned, otherwise the empty sequence
xmldb:is-admin-user
xmldb:is-admin-user($user-id as xs:string) xs:boolean?
Returns true() if user $user-id has DBA role, false() otherwise. Parameters: $user-id : The user-id Returns true() if user has DBA role, false() otherwise
xmldb:last-modified
xmldb:last-modified($collection-uri as item(), $resource as xs:string) xs:dateTime?
Returns the last-modification date of resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the last modification date
xmldb:login
xmldb:login($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?) xs:boolean
Login the user, $user-id, and set it as the owner of the currently executing XQuery. It returns true if the authentication succeeds, false otherwise. If called from a HTTP context the login is cached for the lifetime of the HTTP session and may be used for any XQuery run in that session. If an HTTP session does not already exist, none will be created. Parameters: $collection-uri : The collection URI $user-id : The user-id $password : The password Returns true() on successful authentication and owner elevation, false() otherwise
xmldb:login($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?, $create-session as xs:boolean?) xs:boolean
Login the user, $user-id, and set it as the owner of the currently executing XQuery. It returns true() if the authentication succeeds, false() otherwise. If called from a HTTP context the login is cached for the lifetime of the HTTP session and may be used for any XQueryrun in that session. $create-session specifies whether to create an HTTP session on successful authentication or not. If $create-session is false() or the empty sequence no session will be created if one does not already exist. Parameters: $collection-uri : The collection URI $user-id : The user-id $password : The password $create-session : whether to create the session or not on successful authentication, default false() Returns true() on successful authentication and owner elevation, false() otherwise
xmldb:move
xmldb:move($source-collection-uri as xs:string, $target-collection-uri as xs:string) empty()
Moves the collection $source-collection-uri into the collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $source-collection-uri : The source collection URI $target-collection-uri : The target collection URI
xmldb:move($source-collection-uri as xs:string, $target-collection-uri as xs:string, $resource as xs:string) empty()
Moves the resource $resource from the collection $source-collection-uri into collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $source-collection-uri : The source collection URI $target-collection-uri : The target collection URI $resource : The resource
xmldb:permissions-to-string
xmldb:permissions-to-string($permissions as xs:integer) xs:string?
Formats the resource or collection permissions, $permissions, passed as an integer value into a string. The returned string shows the permissions following the Unix conventions, i.e. all permissions set is returned as rwurwurwu, where the first three chars are for user permissions, followed by group and other users. 'r' denotes read, 'w' write and 'u' update permissions. Parameters: $permissions : The permissions in xs:integer format Returns the permissions as string 'rwu' for, user, group and other
xmldb:register-database
xmldb:register-database($driver as xs:string, $create-db as xs:boolean) xs:boolean
Registers an XMLDB driver class with the XMLDB Database Manager. This is only required if you want to access a database instance different from the one that executes the XQuery. Parameters: $driver : The DB driver $create-db : The flag to create the db if it does not exist Returns true() if successfully registered, false() otherwise
xmldb:reindex
xmldb:reindex($collection-path as xs:string) xs:boolean
Reindex collection $collection-path. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. Parameters: $collection-path : The collection path Returns true() if successfully reindexed, false() otherwise
xmldb:remove
xmldb:remove($collection-uri as xs:string) empty()
Removes the collection $collection-uri and its contents from the database. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI
xmldb:remove($collection-uri as xs:string, $resource as xs:string) empty()
Removes the resource $resource from the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource
xmldb:rename
xmldb:rename($source-collection-uri as xs:string, $new-collection-name as xs:string) empty()
Renames the collection $source-collection-uri with new name $new-collection-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $source-collection-uri : The source collection URI $new-collection-name : The new collection name
xmldb:rename($collection-uri as xs:string, $resource as xs:string, $new-resource-name as xs:string) empty()
Renames the resource $resource in collection $collection-uri with new name $new-resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource $new-resource-name : The new resource name
xmldb:set-collection-permissions
xmldb:set-collection-permissions($collection-uri as xs:string, $user-id as xs:string, $group-id as xs:string, $permissions as xs:integer) empty()
Sets the permissions of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $user-id specifies the user which will become the owner of the resource, $group-id the group, and $permissons the permissions as an xs:integer value. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience. Parameters: $collection-uri : The collection URI $user-id : The user-id $group-id : The group-id $permissions : The permissions
xmldb:set-resource-permissions
xmldb:set-resource-permissions($collection-uri as xs:string, $resource as xs:string, $user-id as xs:string, $group-id as xs:string, $permissions as xs:integer) empty()
Sets the permissions of the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $user-id specifies the user which will become the owner of the resource, $group-id the group, and $permissions the permissions as an xs:integer value. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience. Parameters: $collection-uri : The collection URI $resource : The resource $user-id : The user-id $group-id : The group-id $permissions : The permissions
xmldb:size
xmldb:size($collection-uri as xs:string, $resource as xs:string) xs:long
Returns the estimated size of the resource $resource (in bytes) in the collection $collection-uri. The estimation is based on the number of pages occupied by the resource. If the document is serialized back to a string, its size may be different, since parts of the structural information are stored in compressed form. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Parameters: $collection-uri : The collection URI $resource : The resource Returns the size of the pages, occupied by the resource, in bytes
xmldb:store
xmldb:store($collection-uri as xs:string, $resource-name as xs:string?, $contents as item()) xs:string?
Stores a new resource into the database. The resource is stored in the collection $collection-uri with the name $resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The contents $contents, is either a node, an xs:string, a Java file object or an xs:anyURI. A node will be serialized to SAX. It becomes the root node of the new document. If $contents is of type xs:anyURI, the resource is loaded from that URI. Returns the path to the new document if successfully stored, otherwise an XPathException is thrown. Parameters: $collection-uri : The collection URI $resource-name : The resource name $contents : The contents Returns the path to new resource if sucessfully stored, otherwise the emtpty sequence
xmldb:store($collection-uri as xs:string, $resource-name as xs:string?, $contents as item(), $mime-type as xs:string) xs:string?
Stores a new resource into the database. The resource is stored in the collection $collection-uri with the name $resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The contents $contents, is either a node, an xs:string, a Java file object or an xs:anyURI. A node will be serialized to SAX. It becomes the root node of the new document. If $contents is of type xs:anyURI, the resource is loaded from that URI. The final argument $mime-type is used to specify a mime type. If the mime-type is not a xml based type, the resource will be stored as a binary resource.Returns the path to the new document if successfully stored, otherwise an XPathException is thrown. Parameters: $collection-uri : The collection URI $resource-name : The resource name $contents : The contents $mime-type : The mime type Returns the path to new resource if sucessfully stored, otherwise the emtpty sequence
xmldb:store-files-from-pattern
xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+) xs:string*
Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s). Parameters: $collection-uri : The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $directory : The directory in the file system from where the files are read. $pattern : The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one Returns the sequence of document paths
xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+, $mime-type as xs:string) xs:string*
Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s). Parameters: $collection-uri : The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $directory : The directory in the file system from where the files are read. $pattern : The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one $mime-type : If the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource. Returns the sequence of document paths
xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+, $mime-type as xs:string, $preserve-structure as xs:boolean) xs:string*
Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s). Parameters: $collection-uri : The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $directory : The directory in the file system from where the files are read. $pattern : The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one $mime-type : If the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource. $preserve-structure : If preserve-structure is true(), the filesystem directory structure will be mirrored in the collection. Otherwise all the matching resources, including the ones in sub-directories, will be stored in the collection given in the first argument flatly. Returns the sequence of document paths
xmldb:update
xmldb:update($collection-uri as xs:string, $modifications as node()) xs:integer
Processes an XUpdate request, $modifications, against a collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.The modifications are passed in a document conforming to the XUpdate specification. http://rx4rdf.liminalzone.org/xupdate-wd.html#N1a32e0The function returns the number of modifications caused by the XUpdate. Parameters: $collection-uri : The collection URI $modifications : The XUpdate modifications to be processed Returns the number of modifications, as xs:integer, caused by the XUpdate
xmldb:xcollection
xmldb: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. Parameters: $collection-uris : The collection URIs Returns the document nodes from the specified collections excluding sub-collections
A module for XML validation and grammars functions. (http://exist-db.org/xquery/validation)
validation:clear-grammar-cache
validation:clear-grammar-cache() xs:integer
Remove all cached grammers. Returns the number of deleted grammars.
validation:jaxp
validation:jaxp($instance as item(), $cache-grammars as xs:boolean) xs:boolean
Validate document by parsing $instance. Optionally grammar caching can be enabled. Supported grammars types are '.xsd' and '.dtd'. Parameters: $instance : The document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object. $cache-grammars : Set the flag to true() to enable grammar caching. Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:jaxp($instance as item(), $cache-grammars as xs:boolean, $catalogs as item()*) xs:boolean
Validate document by parsing $instance. Optionally grammar caching can be enabled and an XML catalog can be specified. Supported grammars types are '.xsd' and '.dtd'. Parameters: $instance : The document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object. $cache-grammars : Set the flag to true() to enable grammar caching. $catalogs : The catalogs referenced as xs:anyURI's. Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:jaxp-parse
validation:jaxp-parse($instance as item(), $enable-grammar-cache as xs:boolean, $catalogs as item()*) node()
Parse document in validating mode, all defaults are filled in according to the grammar (xsd). Parameters: $instance : The document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object. $enable-grammar-cache : Set the flag to true() to enable grammar caching. $catalogs : The catalogs referenced as xs:anyURI's. Returns the parsed document.
validation:jaxp-report
validation:jaxp-report($instance as item(), $enable-grammar-cache as xs:boolean) node()
Validate document by parsing $instance. Optionally grammar caching can be enabled. Supported grammars types are '.xsd' and '.dtd'. An XML report is returned. Parameters: $instance : The document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object. $enable-grammar-cache : Set the flag to true() to enable grammar caching. Returns a validation report.
validation:jaxp-report($instance as item(), $enable-grammar-cache as xs:boolean, $catalogs as item()*) node()
Validate document by parsing $instance. Optionally grammar caching can be enabled and an XML catalog can be specified. Supported grammars types are '.xsd' and '.dtd'. An XML report is returned. Parameters: $instance : The document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object. $enable-grammar-cache : Set the flag to true() to enable grammar caching. $catalogs : The catalogs referenced as xs:anyURI's. Returns a validation report.
validation:jaxv
validation:jaxv($instance as item(), $grammars as item()+) xs:boolean
Validate document specified by $instance using the schemas in $grammars. Based on functionality provided by 'javax.xml.validation.Validator'. Only '.xsd' grammars are supported. Parameters: $instance : The document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object. $grammars : One of more XML Schema documents (.xsd), referenced as xs:anyURI, a node (element or returned by fn:doc()) or as Java file objects. Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:jaxv-report
validation:jaxv-report($instance as item(), $grammars as item()+) node()
Validate document specified by $instance using the schemas in $grammars. Based on functionality provided by 'javax.xml.validation.Validator'. Only '.xsd' grammars are supported. An XML report is returned. Parameters: $instance : The document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object. $grammars : One of more XML Schema documents (.xsd), referenced as xs:anyURI, a node (element or returned by fn:doc()) or as Java file objects. Returns a validation report.
validation:jing
validation:jing($instance as item(), $grammar as item()) xs:boolean
Validate document using 'Jing'. Supported grammar documents extensions are ".xsd" ".rng" ".rnc" ".sch" and ".nvdl". Based on functionality provided by 'com.thaiopensource.validate.ValidationDriver'. Parameters: $instance : The document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object. $grammar : The grammar document as node (element of returned by fn:doc()), xs:anyURI, returned by util:binary-doc() or as a Java file object. Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:jing-report
validation:jing-report($instance as item(), $grammar as item()) node()
Validate document using 'Jing'. Supported grammar documents extensions are ".xsd" ".rng" ".rnc" ".sch" and ".nvdl". Based on functionality provided by 'com.thaiopensource.validate.ValidationDriver'. An XML report is returned. Parameters: $instance : The document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object. $grammar : The grammar document as node (element of returned by fn:doc()), xs:anyURI, returned by util:binary-doc() or as a Java file object. Returns a validation report.
validation:pre-parse-grammar
validation:pre-parse-grammar($grammar as xs:anyURI*) xs:string*
Pre parse grammars and add to grammar cache. Only XML schemas (.xsd) are supported. Parameters: $grammar : Reference to grammar. Returns sequence of namespaces of preparsed grammars.
validation:show-grammar-cache
validation:show-grammar-cache() node()
Show all cached grammars. Returns an XML document containing details on all cached grammars.
validation:validate
validation:validate($instance as item()) xs:boolean
Validate xml. The grammar files (DTD, XML Schema) are resolved using the global catalog file(s). Parameters: $instance : The document referenced as xs:anyURI or a node (element or returned by fn:doc()) Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:validate($instance as item(), $grammar as xs:anyURI) node()
Validate document by using a specific grammar. Parameters: $instance : The document referenced as xs:anyURI or a node (element or returned by fn:doc()) $grammar : The reference to an OASIS catalog file (.xml), a collection (path ends with '/') or a grammar document. Supported grammar documents extensions are ".dtd" ".xsd" ".rng" ".rnc" ".sch" and ".nvdl". Returns true() if the document is valid and no single problem occured, false() for all other conditions. For detailed validation information use the corresponding -report() function.
validation:validate-report
validation:validate-report($instance as item()) node()
Validate xml. The grammar files (DTD, XML Schema) are resolved using the global catalog file(s). An xml report is returned. Parameters: $instance : The document referenced as xs:anyURI or a node (element or returned by fn:doc()) Returns a validation report.
validation:validate-report($instance as item(), $grammar as xs:anyURI) node()
Validate document by using a specific grammar. An xml report is returned. Parameters: $instance : The document referenced as xs:anyURI or a node (element or returned by fn:doc()) $grammar : The reference to an OASIS catalog file (.xml), a collection (path ends with '/') or a grammar document. Supported grammar documents extensions are ".dtd" ".xsd" ".rng" ".rnc" ".sch" and ".nvdl". Returns a validation report.
A module for various utility extension functions. (http://exist-db.org/xquery/util)
util:base-to-integer
util:base-to-integer($number as item(), $base as xs:integer) xs:integer
Converts the number $number from base $base to xs:integer. Parameters: $number : The number to convert $base : The base of $number Returns the xs:integer representation of $number in base $base
util:binary-doc
util:binary-doc($binary-resource as xs:string?) xs:base64Binary?
Retrieves the binary resource and returns its contents as a value of type xs:base64Binary. An empty sequence is returned if the resource could not be found or $binary-resource was empty. Parameters: $binary-resource : The path to the binary resource Returns the binary document
util:binary-doc-available
util:binary-doc-available($binary-resource as xs:string?) xs:boolean
Checks if the binary resource identified by $binary-resource is available. Parameters: $binary-resource : The path to the binary resource Returns true if the binary document is available
util:binary-to-string
util:binary-to-string($binary-resource as xs:base64Binary?) xs:string?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8. Parameters: $binary-resource : The binary resource Returns the string containing the encoded binary resource
util:binary-to-string($binary-resource as xs:base64Binary?, $encoding as xs:string) xs:string?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8. Parameters: $binary-resource : The binary resource $encoding : The encoding type. i.e. 'UTF-8' Returns the string containing the encoded binary resource
util:call
util:call($function-reference as function, $parameters as item()*, ...) item()*
Invokes a first-class function reference created by util:function. The function to be called is passed as the first argument. All remaining arguments are forwarded to the called function. Parameters: $function-reference : The function to ba called $parameters : The parameters to be passed into the function Returns the results from the function called
util:catch
util:catch($java-classnames as xs:string+, $try-code-blocks as item()*, $catch-code-blocks as item()*) item()*
This function corresponds to a try-catch statement in Java. The code block in $try-code-blocks will be put inside a try-catch statement. If an exception is thrown while executing $try-code-blocks, the function checks the name of the exception and calls $catch-code-blocks if it matches one of the fully qualified Java class names specified in $java-classnames. A value of "*" in $java-classnames will catch all java exceptions Parameters: $java-classnames : The list of one or more fully qualified Java class names. An entry of '*' will catch all java exceptions. $try-code-blocks : The code blocks that will be put inside of a the try part of the try-catch statement. $catch-code-blocks : The code blocks that will be will called if the catch matches one of the $java-classnames Returns the results from the try-catch
util:collations
util:collations() xs:string*
Returns a sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI. Returns the sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI.
util:collection-name
util:collection-name($node-or-path-string as item()?) xs:string?
Returns the name of the collection from a passed node or path string. If the argument is a node, the function returns the name of the collection to which the node's document belongs. If the argument is a string, it is interpreted as path to a resource and the function returns the computed parent collection path for this resource. Parameters: $node-or-path-string : The document node or a path string. Returns the name of the collection.
util:compile
util:compile($expression as xs:string) xs:string
Dynamically evaluates the XPath/XQuery expression specified in $expression within the current instance of the query engine. Parameters: $expression : The XPath/XQuery expression. Returns the results of the expression
util:declare-namespace
util:declare-namespace($prefix as xs:string, $namespace-uri as xs:anyURI) empty()
Dynamically declares a namespace/prefix mapping for the current context. Parameters: $prefix : The prefix to be assigned to the namespace $namespace-uri : The namespace URI
util:declare-option
util:declare-option($name as xs:string, $option as xs:string) empty()
Dynamically declares a serialization option as with 'declare option'. Parameters: $name : The serialization option name $option : The serialization option value
util:deep-copy
util:deep-copy($item as item()?) item()?
Performs a Deep Clone of the passed in item. Parameters: $item : The item to be cloned Returns the item clone
util:describe-function
util:describe-function($function-name as xs:QName) node()
Describes a built-in function. Returns an element describing the function signature. Parameters: $function-name : The name of the function to get the signature of Returns the signature of the function
util:disable-profiling
util:disable-profiling() empty()
Disable profiling output within the query.
util:doctype
util:doctype($doctype as xs:string+, ...) node()*
Returns the document nodes of the documents with the given DOCTYPE(s). Parameters: $doctype : The DOCTYPE of the documents to find Returns the document nodes
util:document-id
util:document-id($node-or-path as item()) xs:int?
Returns the internal integer id of a document. The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned. Parameters: $node-or-path : The node or a string path pointing to a resource in the database. Returns the ID of the document
util:document-name
util:document-name($node-or-path as item()) xs:string?
Returns the name of a document (excluding the collection path). The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned. Parameters: $node-or-path : The node or a string path pointing to a resource in the database. Returns the name of the document
util:enable-profiling
util:enable-profiling($verbosity as xs:int) empty()
Enable profiling output within the query. The profiling starts with this function call and will end with a call to 'disable-profiling'. Argument $verbosity specifies the verbosity. All other profiling options can be configured via the 'declare option exist:profiling ...' in the query prolog. Parameters: $verbosity : The verbosity of the profiling
util:eval
util:eval($expression as item()) node()*
Dynamically evaluates an XPath/XQuery expression. Parameters: $expression : The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. Returns the results of the evaluated XPath/XQuery expression
util:eval($expression as item(), $cache-flag as xs:boolean) node()*
Dynamically evaluates an XPath/XQuery expression. Parameters: $expression : The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $cache-flag : The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. Returns the results of the evaluated XPath/XQuery expression
util:eval-inline
util:eval-inline($inline-context as item()*, $expression as item()) item()*
Dynamically evaluates an XPath/XQuery expression. Parameters: $inline-context : The inline context $expression : The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. Returns the results of the evaluated XPath/XQuery expression
util:eval-with-context
util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean) node()*
Dynamically evaluates an XPath/XQuery expression. Parameters: $expression : The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $context : The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. $cache-flag : The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. Returns the results of the evaluated XPath/XQuery expression
util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean, $eval-context-item as item()?) node()*
Dynamically evaluates an XPath/XQuery expression. Parameters: $expression : The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $context : The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. $cache-flag : The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. $eval-context-item : the context item against which the expression will be evaluated Returns the results of the evaluated XPath/XQuery expression
util:exclusive-lock
util:exclusive-lock($nodes as node()*, $expression as item()*) item()*
Puts an exclusive lock on the owner documents of all nodes in the first argument $nodes. Then evaluates the expressions in the second argument $expression and releases the acquired locks after their completion. Parameters: $nodes : The nodes whose owning documents will have exclusive locks set. $expression : The expression(s) that are to be evaluated before the acquired locks are released. Returns the results of the evaluated expression(s)
util:expand
util:expand($node as node()*) node()*
Creates an in-memory copy of the passed node set, using the specified serialization options. By default, full-text match terms will be tagged with &lt;exist:match&gt; and XIncludes will be expanded. Parameters: $node : The node(s) to create in-memory copies of. Returns the results
util:expand($node as node()*, $serialization-parameters as xs:string) node()*
Creates an in-memory copy of the passed node set, using the specified serialization options. By default, full-text match terms will be tagged with &lt;exist:match&gt; and XIncludes will be expanded. Serialization parameters can be set in the second argument, which accepts the same parameters as the exist:serialize option. Parameters: $node : The node(s) to create in-memory copies of. $serialization-parameters : The serialization parameters Returns the results
util:extract-docs
util:extract-docs($uri as xs:string) node()?
Returns an XML document which describes the functions available in a given module. The module is identified through its module namespace URI, which is passed as an argument. The function returns a module documentation in XQDoc format. Parameters: $uri : The namespace URI of the function module Returns the xqdocs for the function module
util:function
util:function($name as xs:QName, $arity as xs:integer) function
Creates a reference to an XQuery function which can later be called from util:call. This allows for higher-order functions to be implemented in XQuery. A higher-order function is a function that takes another function as argument. The first argument represents the name of the function, which should bea valid QName. The second argument is the arity (number of parameters) of the function. If no function can be found that matches the name and arity, an error is thrown. Please note: the arguments to this function have to be literals or need to be resolvable at compile time at least. Parameters: $name : The name of the function $arity : The arity of the function Returns the reference to the XQuery function
util:get-fragment-between
util:get-fragment-between($beginning-node as node()?, $ending-node as node()?, $make-fragment as xs:boolean?) xs:string
Returns an xml fragment or a sequence of nodes between two elements (normally milestone elements). The $beginning-node represents the first node/milestone element, $ending-node, the second one. The third argument, $make-fragment, is a boolean value for the path completion. If it is set to true() the result sequence is wrapped into a parent element node. Example call of the function for getting the fragment between two TEI page break element nodes: let $fragment := util:get-fragment-between(//pb[1], //pb[2], true()) Parameters: $beginning-node : The first node/milestone element $ending-node : The second node/milestone element $make-fragment : The flag make a fragment. Returns the string containing the fragments between the two node/milestone elements.
util:get-module-description
util:get-module-description($namespace-uri as xs:string) xs:string
Returns a short description of the module identified by the namespace URI. Parameters: $namespace-uri : The namespace URI of the module Returns the description of the active function module identified by the namespace URI
util:get-sequence-type
util:get-sequence-type($sequence-type as xs:anyType*) xs:string
Returns the string representation of the type of sequence. Parameters: $sequence-type : The type of sequence Returns the string representation of the type of sequence
util:hash
util:hash($message as item(), $algorithm as xs:string) xs:string
Calculates a hashcode from a string based on a specified algorithm. Parameters: $message : The string to generate the hashcode from $algorithm : The algorithm used to generate the hashcode Returns the hashcode
util:hash($message as item(), $algorithm as xs:string, $base64flag as xs:boolean) xs:string
Calculates a hashcode from a string based on a specified algorithm. Parameters: $message : The string to generate the hashcode from $algorithm : The algorithm used to generate the hashcode $base64flag : The flag that specifies whether to return the result as Base64 encoded Returns the hashcode
util:import-module
util:import-module($module-uri as xs:anyURI, $prefix as xs:string, $location as xs:anyURI) empty()
Dynamically imports an XQuery module into the current context. The parameters have the same meaning as in an 'import module ...' expression in the query prolog. Parameters: $module-uri : The namespace URI of the module $prefix : The prefix to be assigned to the namespace $location : The location of the module
util:index-key-documents
util:index-key-documents($nodes as node()*, $value as xdt:anyAtomicType) xs:integer?
Return the number of documents for an indexed value. Parameters: $nodes : The nodes whose content is indexed $value : The indexed value to search for Returns the number of documents for the indexed value
util:index-key-documents($nodes as node()*, $value as xdt:anyAtomicType, $index as xs:string) xs:integer?
Return the number of documents for an indexed value. Parameters: $nodes : The nodes whose content is indexed $value : The indexed value to search for $index : The index in which the search is made Returns the number of documents for the indexed value
util:index-key-occurrences
util:index-key-occurrences($nodes as node()*, $value as xdt:anyAtomicType) xs:integer?
Return the number of occurrences for an indexed value. Parameters: $nodes : The nodes whose content is indexed $value : The indexed value to search for Returns the number of occurrences for the indexed value
util:index-key-occurrences($nodes as node()*, $value as xdt:anyAtomicType, $index as xs:string) xs:integer?
Return the number of occurrences for an indexed value. Parameters: $nodes : The nodes whose content is indexed $value : The indexed value to search for $index : The index in which the search is made Returns the number of occurrences for the indexed value
util:index-keys
util:index-keys($node-set as node()*, $start-value as xdt:anyAtomicType, $function-reference as function, $max-number-returned as xs:int) item()*
Can be used to query existing range indexes defined on a set of nodes. All index keys defined for the given node set are reported to a callback function. The function will check for indexes defined on path as well as indexes defined by QName. Parameters: $node-set : The node set $start-value : Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. $function-reference : The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. $max-number-returned : The maximum number of returned keys Returns the results of the eval of the $function-reference
util:index-keys($node-set as node()*, $start-value as xdt:anyAtomicType, $function-reference as function, $max-number-returned as xs:int, $index as xs:string) item()*
Can be used to query existing range indexes defined on a set of nodes. All index keys defined for the given node set are reported to a callback function. The function will check for indexes defined on path as well as indexes defined by QName. Parameters: $node-set : The node set $start-value : Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. $function-reference : The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. $max-number-returned : The maximum number of returned keys $index : The index in which the search is made Returns the results of the eval of the $function-reference
util:index-type
util:index-type($set-of-nodes as node()*) xs:string?
Returns the range index type for a set of nodes or an empty sequence if no index is defined. Parameters: $set-of-nodes : The set of nodes Returns the range index type
util:integer-to-base
util:integer-to-base($number as xs:integer, $base as xs:integer) xs:string
Converts the xs:integer $number (unsigned) into base $base as xs:string. Bases 2, 8, and 16 are supported. Parameters: $number : The number to convert $base : The base of $number Returns the xs:string representation of $number in base $base
util:is-binary-doc
util:is-binary-doc($binary-resource as xs:string?) xs:boolean
Checks if the resource identified by $binary-resource is a binary resource. Parameters: $binary-resource : The path to the binary resource Returns true if the resource is a binary document
util:is-module-registered
util:is-module-registered($namespace-uri as xs:string) xs:boolean
Returns a Boolean value if the module identified by the namespace URI is registered. Parameters: $namespace-uri : The namespace URI of the module Returns true if the namespace URI is registered as an active function module
util:log
util:log($priority as xs:string, $message as item()*) empty()
Logs the message to the current logger. Parameters: $priority : The logging priority: 'error', 'warn', 'debug', 'info', 'trace' $message : The message to log
util:log-app
util:log-app($priority as xs:string, $logger-name as xs:string, $message as item()*) empty()
Logs the message to the named logger Parameters: $priority : The logging priority: 'error', 'warn', 'debug', 'info', 'trace' $logger-name : The name of the logger, eg: my.app.log $message : The message to log
util:log-system-err
util:log-system-err($message as item()*) empty()
Logs the message to System.err. Parameters: $message : The message to log
util:log-system-out
util:log-system-out($message as item()*) empty()
Logs the message to System.out. Parameters: $message : The message to log
util:mapped-modules
util:mapped-modules() xs:string+
Returns a sequence containing the namespace URIs of all XQuery modules which are statically mapped to a source location in the configuration file. This does not include any built in modules. Returns the sequence of all of the active function modules namespace URIs
util:node-by-id
util:node-by-id($document as node(), $node-id as xs:string) node()
Retrieves a node by its internal node-id. The document is specified via the first argument. It may either be a document node or another node from the same document from which the target node will be retrieved by its id. The second argument is the internal node-id, specified as a string. Please note: the function does not check if the passed id does really point to an existing node. It just returns a pointer, which may thus be invalid. Parameters: $document : The document whose node is to be retrieved by its id $node-id : The internal node id Returns the node
util:node-id
util:node-id($node as node()) xs:string
Returns the internal node-id of a node. The internal node-id uniquely identifies a node within its document. It is encoded as a long number. Parameters: $node : The node to get the internal node-id from Returns the internal node-id
util:node-xpath
util:node-xpath($node as node()) xs:string?
Returns the XPath for a Node. Parameters: $node : The node to retrieve the XPath to Returns the XPath expression of the node
util:parse
util:parse($to-be-parsed as xs:string?) node()*
Parses the passed string value into an XML fragment. The string has to be well-formed XML. An empty sequence is returned if the argument is an empty string or sequence. Parameters: $to-be-parsed : The string to be parsed Returns the XML fragment parsed from the string
util:parse-html
util:parse-html($to-be-parsed as xs:string?) node()*
Parses the passed string value into an XML fragment. The HTML string may not be well-formed XML. It will be passed through the Neko HTML parser to make it well-formed. An empty sequence is returned if the argument is an empty string or sequence. Parameters: $to-be-parsed : The string to be parsed Returns the XML fragment parsed from the string
util:qname-index-lookup
util:qname-index-lookup($qname as xs:QName, $comparison-value as xdt:anyAtomicType) node()*
Can be used to query existing qname indexes defined on a set of nodes. Parameters: $qname : The QName $comparison-value : The comparison value Returns the result
util:random
util:random() xs:double
Returns a random number between 0.0 and 1.0 Returns a random number between 0.0 and 1.0
util:random($max as xs:integer) xs:integer
Returns a random number between 0 and $max Parameters: $max : The maximum value for the random number. Returns a random number between 0 and $max
util:registered-functions
util:registered-functions() xs:string+
Returns a sequence containing the QNames of all functions currently known to the system, including functions in imported and built-in modules. Returns the sequence of function names
util:registered-functions($namespace-uri as xs:string) xs:string+
Returns a sequence containing the QNames of all functions declared in the module identified by the specified namespace URI. An error is raised if no module is found for the specified URI. Parameters: $namespace-uri : The namespace URI of the function module Returns the sequence of function names
util:registered-modules
util:registered-modules() xs:string+
Returns a sequence containing the namespace URIs of all modules currently known to the system, including built in and imported modules. Returns the sequence of all of the active function modules namespace URIs
util:serialize
util:serialize($node-set as node()*, $parameters as xs:string*) xs:string?
Returns the Serialized node set passed in parameter $node-set. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. Parameters: $node-set : The node set to serialize $parameters : The serialization parameters Returns the string containing the serialized node set.
util:serialize($a as node()*, $b as xs:string, $c as xs:string*) xs:boolean?
Writes the node set passed in parameter $a into a file on the file system. The full path to the file is specified in parameter $b. $c contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. False is returned if the specified file can not be created or is not writable, true on success. The empty sequence is returned if the argument sequence is empty.
util:shared-lock
util:shared-lock($nodes as node()*, $expression as item()*) item()*
Puts a shared lock on the owner documents of all nodes in the first argument $nodes. Then evaluates the expressions in the second argument $expression and releases the acquired locks aftertheir completion. Parameters: $nodes : The nodes that the shared lock will be placed on their owning documents. $expression : The expression to be evaluated before the acquired locks are released. Returns the results of the evaluation of the expression(s)
util:string-to-binary
util:string-to-binary($encoded-string as xs:string?) xs:base64Binary?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8. Parameters: $encoded-string : The string containing the encoded binary resource Returns the binary resource
util:string-to-binary($encoded-string as xs:string?, $encoding as xs:string) xs:base64Binary?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8. Parameters: $encoded-string : The string containing the encoded binary resource $encoding : the encoding type. i.e. 'UTF-8' Returns the binary resource
util:system-date
util:system-date() xs:date
Returns the current xs:date (with timezone) as reported by the Java method System.currentTimeMillis(). Contrary to fn:current-date, this function is not stable, i.e. the returned xs:date will change during the evaluation time of a query and can be used to measure time differences. Returns the current xs:date (with timezone)
util:system-dateTime
util:system-dateTime() xs:dateTime
Returns the current xs:dateTime (with timezone) as reported by the Java method System.currentTimeMillis(). Contrary to fn:current-dateTime, this function is not stable, i.e. the returned xs:dateTime will change during the evaluation time of a query and can be used to measure time differences. Returns the current xs:dateTime (with timezone)
util:system-property
util:system-property($property-name as xs:string) xs:string?
Returns the value of a system property. Similar to the corresponding XSLT function. Predefined properties are: vendor, vendor-url, product-name, product-version, product-build, and all Java system properties. Parameters: $property-name : The name of the system property to retrieve the value of. Returns the value of the named system property
util:system-time
util:system-time() xs:time
Returns the current xs:time (with timezone) as reported by the Java method System.currentTimeMillis(). Contrary to fn:current-time, this function is not stable, i.e. the returned xs:time will change during the evaluation time of a query and can be used to measure time differences. Returns the current xs:time (with timezone)
util:unescape-uri
util:unescape-uri($escaped-string as xs:string, $encoding as xs:string) xs:string
Returns an un-escaped URL escaped string with the encoding scheme (e.g. "UTF-8"). Decodes encoded sensitive characters from a URL, for example "%2F" becomes "/", i.e. does the oposite to escape-uri() Parameters: $escaped-string : The escaped string to be un-escaped $encoding : The encoding scheme to use in the un-escaping of the string Returns the un-escaped string
util:uuid
util:uuid() xs:string
Generate a version 4 (random) universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6 Returns a generated UUID string
util:uuid($name as item()) xs:string
Generate a version 3 universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6 Parameters: $name : The input value for UUID calculation. Returns a generated UUID string
A module for dealing with XSL transformations. (http://exist-db.org/xquery/transform)
transform:stream-transform
transform:stream-transform($node-tree as node()?, $stylesheet as item(), $parameters as node()?) empty()
Applies an XSL stylesheet to the node tree passed as first argument. The parameters are the same as for the transform function. stream-transform can only be used within a servlet context. Instead of returning the transformed document fragment, it directly streams its output to the servlet's output stream. It should thus be the last statement in the XQuery. Parameters: $node-tree : The source-document (node tree) $stylesheet : The XSL stylesheet $parameters : The transformer parameters
transform:stream-transform($node-tree as node()?, $stylesheet as item(), $parameters as node()?, $serialization-options as xs:string) empty()
Applies an XSL stylesheet to the node tree passed as first argument. The parameters are the same as for the transform function. stream-transform can only be used within a servlet context. Instead of returning the transformed document fragment, it directly streams its output to the servlet's output stream. It should thus be the last statement in the XQuery. Parameters: $node-tree : The source-document (node tree) $stylesheet : The XSL stylesheet $parameters : The transformer parameters $serialization-options : The serialization options
transform:transform
transform:transform($node-tree as node()?, $stylesheet as item(), $parameters as node()?) node()?
Applies an XSL stylesheet to the node tree passed as first argument. The stylesheet is specified in the second argument. This should either be an URI or a node. If it is an URI, it can either point to an external location or to an XSL stored in the db by using the 'xmldb:' scheme. Stylesheets are cached unless they were just created from an XML fragment and not from a complete document. Stylesheet parameters may be passed in the third argument using an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>. There are two special parameters named "exist:stop-on-warn" and "exist:stop-on-error". If set to value "yes", eXist will generate an XQuery error if the XSL processor reports a warning or error. Parameters: $node-tree : The source-document (node tree) $stylesheet : The XSL stylesheet $parameters : The transformer parameters Returns the transformed result (node tree)
transform:transform($node-tree as node()?, $stylesheet as item(), $parameters as node()?, $serialization-options as xs:string) node()?
Applies an XSL stylesheet to the node tree passed as first argument. The stylesheet is specified in the second argument. This should either be an URI or a node. If it is an URI, it can either point to an external location or to an XSL stored in the db by using the 'xmldb:' scheme. Stylesheets are cached unless they were just created from an XML fragment and not from a complete document. Stylesheet parameters may be passed in the third argument using an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>. There are two special parameters named "exist:stop-on-warn" and "exist:stop-on-error". If set to value "yes", eXist will generate an XQuery error if the XSL processor reports a warning or error. The fourth argument specifies serialization options in the same way as if they were passed to "declare option exist:serialize" expression. An additional serialization option, xinclude-path, is supported, which specifies a base path against which xincludes will be expanded (if there are xincludes in the document). A relative path will be relative to the current module load path. Parameters: $node-tree : The source-document (node tree) $stylesheet : The XSL stylesheet $parameters : The transformer parameters $serialization-options : The serialization options Returns the transformed result (node tree)
A module for text searching extension functions. (http://exist-db.org/xquery/text)
text:filter
text:filter($text as xs:string, $regularexpression as xs:string) xs:string*
Filter substrings that match the regular expression in the text. Parameters: $text : The text to filter $regularexpression : The regular expression to perform against the text Returns the substrings
text:filter-nested
text:filter-nested($node-set as node()*) node()*
Filters out all nodes in the node set, which do have descendant nodes in the same node set. This is useful if you do a combined query like //(a|b)[. &= $terms] and some 'b' nodes are nested within 'a' nodes, but you only want to see the innermost matches, i.e. the 'b' nodes, not the 'a' nodes containing 'b' nodes. Parameters: $node-set : The node set Returns a node set containing nodes that do not have descendent nodes.
text:fuzzy-index-terms
text:fuzzy-index-terms($term as xs:string?) xs:string*
Compares the specified argument against the contents of the fulltext index. Returns a sequence of strings which are similar to the argument. Similarity is based on Levenshtein distance. This function may not be useful in its current form and is subject to change. Parameters: $term : The term Returns a sequence of strings which are similar to the argument $term
text:fuzzy-match-all
text:fuzzy-match-all($source as node()*, $keyword as xs:string, ...) node()*
Fuzzy keyword search, which compares strings based on the Levenshtein distance (or edit distance). The function tries to match each of the keywords specified in the keyword string against the string value of each item in the sequence $source. Parameters: $source : The source $keyword : The keyword string Returns the sequence of nodes that match the keywords
text:fuzzy-match-any
text:fuzzy-match-any($source as node()*, $keyword as xs:string, ...) node()*
Fuzzy keyword search, which compares strings based on the Levenshtein distance (or edit distance). The function tries to match any of the keywords specified in the keyword string against the string value of each item in the sequence $source. Parameters: $source : The source $keyword : The keyword string Returns the sequence of nodes that match the keywords
text:groups
text:groups($text as xs:string, $regularexpression as xs:string) xs:string*
Tries to match the string in $text to the regular expression. Returns an empty sequence if the string does not match, or a sequence whose first item is the entire string, and whose following items are the matched groups. Parameters: $text : The text to filter $regularexpression : The regular expression to perform against the text Returns an empty sequence if the string does not match, or a sequence whose first item is the entire string, and whose following items are the matched groups.
text:groups($text as xs:string, $regularexpression as xs:string, $flags as xs:string) xs:string*
Tries to match the string in $text to the regular expression, using the flags specified. Returns an empty sequence if the string does not match, or a sequence whose first item is the entire string, and whose following items are the matched groups. Parameters: $text : The text to filter $regularexpression : The regular expression to perform against the text $flags : The flags Returns an empty sequence if the string does not match, or a sequence whose first item is the entire string, and whose following items are the matched groups.
text:highlight-matches
text:highlight-matches($source as text()*, $callback-function-ref as function, $parameters as item()*) node()*
Highlight matching strings within text nodes that resulted from a fulltext search. When searching with one of the fulltext operators or functions, eXist keeps track of the fulltext matches within the text. Usually, the serializer will mark those matches by enclosing them into an 'exist:match' element. One can then use an XSLT stylesheet to replace those match elements and highlight matches to the user. However, this is not always possible, so Instead of using an XSLT to post-process the serialized output, the highlight-matches function provides direct access to the matching portions of the text within XQuery. The function takes a sequence of text nodes as first argument $source and a callback function (defined with util:function) as second parameter. $parameters may contain a sequence of additional values that will be passed to the callback functions third parameter. Text nodes without matches will be returned as they are. However, if the text contains a match marker, the matching character sequence is reported to the callback function, and the result of the function call is inserted into the resulting node set where the matching sequence occurred. For example, you can use this to mark all matching terms with a <span class="highlight">abc</span>. Parameters: $source : The sequence of text nodes $callback-function-ref : The callback function (defined with util:function) $parameters : The sequence of additional values that will be passed to the callback functions third parameter. Returns the source with the added highlights
text:index-terms
text:index-terms($nodes as node()*, $start as xs:string?, $function as function, $returnMax as xs:int) item()*
This function can be used to collect some information on the distribution of index terms within a set of nodes. The set of nodes is specified in the first argument $nodes. The function returns term frequencies for all terms in the index found in descendants of the nodes in $nodes. The second argument $start specifies a start string. Only terms starting with the specified character sequence are returned. If $nodes is the empty sequence, all terms in the index will be selected. $function is a function reference, which points to a callback function that will be called for every term occurrence. $returnMax defines the maximum number of terms that should be reported. The function reference for $function can be created with the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current term as found in the index as xs:string, 2) a sequence containing four int values: a) the overall frequency of the term within the node set, b) the number of distinct documents in the node set the term occurs in, c) the current position of the term in the whole list of terms returned, d) the rank of the current term in the whole list of terms returned. Parameters: $nodes : The set of nodes in which the returned tokens occur $start : The optional start string $function : The callback function reference $returnMax : The maximum number of terms to report Returns the results from the evaluation of the function reference
text:index-terms($nodes as node()*, $qnames as xs:QName+, $start as xs:string?, $function as function, $returnMax as xs:int) item()*
This version of the index-terms function is to be used with indexes that were defined on a specific element or attribute QName. The second argument lists the QNames or elements or attributes for which occurrences should bereturned. Otherwise, the function behaves like the 4-argument version. Parameters: $nodes : The set of nodes in which the returned tokens occur $qnames : One or more element or attribute names for which index terms are returned $start : The optional start string $function : The callback function reference $returnMax : The maximum number of terms to report Returns the results from the evaluation of the function reference
text:kwic-display
text:kwic-display($text as text()*, $width as xs:positiveInteger, $callback-function as function, $parameters as item()*) node()*
Deprecated: kwic functionality is now provided by an XQuery module, see http://exist-org/kwic.html.This function takes a sequence of text nodes in $a, containing matches from a fulltext search. It highlights matching strings within those text nodes in the same way as the text:highlight-matches function. However, only a defined portion of the text surrounding the first match (and maybe following matches) is returned. If the text preceding the first match is larger than the width specified in the second argument $b, it will be truncated to fill no more than (width - keyword-length) / 2 characters. Likewise, the text following the match will be truncated in such a way that the whole string sequence fits into width characters. The third parameter $c is a callback function (defined with util:function). $d may contain an additional sequence of values that will be passed to the last parameter of the callback function. Any matching character sequence is reported to the callback function, and the result of the function call is inserted into the resulting node set where the matching sequence occurred. For example, you can use this to mark all matching terms with a <span class="highlight">abc</span>. The callback function should take 3 or 4 arguments: 1) the text sequence corresponding to the match as xs:string, 2) the text node to which this match belongs, 3) the sequence passed as last argument to kwic-display. If the callback function accepts 4 arguments, the last argument will contain additional information on the match as a sequence of 4 integers: a) the number of the match if there's more than one match in a text node - the first match will be numbered 1; b) the offset of the match into the original text node string; c) the length of the match as reported by the index. Parameters: $text : The text nodes $width : The width $callback-function : The callback function $parameters : The parameters passed into the last argument of the callback function Returns the results
text:kwic-display($text as text()*, $width as xs:positiveInteger, $callback-function as function, $result-callback as function, $parameters as item()*) node()*
This function takes a sequence of text nodes in $a, containing matches from a fulltext search. It highlights matching strings within those text nodes in the same way as the text:highlight-matches function. However, only a defined portion of the text surrounding the first match (and maybe following matches) is returned. If the text preceding the first match is larger than the width specified in the second argument $b, it will be truncated to fill no more than (width - keyword-length) / 2 characters. Likewise, the text following the match will be truncated in such a way that the whole string sequence fits into width characters. The third parameter $c is a callback function (defined with util:function). $d may contain an additional sequence of values that will be passed to the last parameter of the callback function. Any matching character sequence is reported to the callback function, and the result of the function call is inserted into the resulting node set where the matching sequence occurred. For example, you can use this to mark all matching terms with a <span class="highlight">abc</span>. The callback function should take 3 or 4 arguments: 1) the text sequence corresponding to the match as xs:string, 2) the text node to which this match belongs, 3) the sequence passed as last argument to kwic-display. If the callback function accepts 4 arguments, the last argument will contain additional information on the match as a sequence of 4 integers: a) the number of the match if there's more than one match in a text node - the first match will be numbered 1; b) the offset of the match into the original text node string; c) the length of the match as reported by the index. Parameters: $text : The text nodes $width : The width $callback-function : The callback function $result-callback : The result callback function $parameters : The parameters passed into the last argument of the callback function Returns the results
text:make-token
text:make-token($text as xs:string) xs:string*
Split a string into tokens Parameters: $text : The string to tokenize Returns a sequence of tokens
text:match-all
text:match-all($source as node()*, $regular-expression as xs:string+) node()*
Tries to match each of the regular expression strings against the keywords contained in the fulltext index. The keywords found are then compared to the node set in $source. Every node containing ALL of the keywords is copied to the result sequence. By default, a keyword is considered to match the pattern if any substring of the keyword matches. To change this behaviour, use the 3-argument version of the function and specify flag 'w'. With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Parameters: $source : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index Returns the sequence of all of the matching nodes
text:match-all($source as node()*, $regular-expression as xs:string+, $flag as xs:string) node()*
Tries to match each of the regular expression strings against the keywords contained in the fulltext index. The keywords found are then compared to the node set in $source. Every node containing ALL of the keywords is copied to the result sequence. By default, a keyword is considered to match the pattern if any substring of the keyword matches. To change this behaviour, use the 3-argument version of the function and specify flag 'w'. With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Parameters: $source : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index $flag : With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Returns the sequence of all of the matching nodes
text:match-any
text:match-any($source as node()*, $regular-expression as xs:string+) node()*
Tries to match each of the regular expression strings against the keywords contained in the fulltext index. The keywords found are then compared to the node set in $source. Every node containing ANY of the keywords is copied to the result sequence. By default, a keyword is considered to match the pattern if any substring of the keyword matches. To change this behaviour, use the 3-argument version of the function and specify flag 'w'. With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Parameters: $source : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index Returns the sequence of all of the matching nodes
text:match-any($source as node()*, $regular-expression as xs:string+, $flag as xs:string) node()*
Tries to match each of the regular expression strings against the keywords contained in the fulltext index. The keywords found are then compared to the node set in $source. Every node containing ANY of the keywords is copied to the result sequence. By default, a keyword is considered to match the pattern if any substring of the keyword matches. To change this behaviour, use the 3-argument version of the function and specify flag 'w'. With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Parameters: $source : The node set that is to be searched for the keyword set $regular-expression : The regular expressions to be matched against the fulltext index $flag : With 'w' specified, the regular expression is matched against the entire keyword, i.e. 'explain.*' will match 'explained' , but not 'unexplained'. Returns the sequence of all of the matching nodes
text:match-count
text:match-count($source as node()?) xs:integer
Counts the number of fulltext matches within the nodes and subnodes in $source. Parameters: $source : The node and subnodes to do the fulltext match on Returns the count
text:text-rank
text:text-rank($text as node()?) xs:double
This is just a skeleton for a possible ranking function. Don't use this. Parameters: $text : The text to rank Returns the ranking of the text
A module for retrieving information about eXist and the system. (http://exist-db.org/xquery/system)
system:as-user
system:as-user($username as xs:string, $password as xs:string?, $code-block as item()*) item()*
A pseudo-function to execute a limited block of code as a different user. The first argument is the name of the user, the second is the password. If the user can be authenticated, the function will execute the code block given in the third argument with the permissions of that user andreturns the result of the execution. Before the function completes, it switches the current user back to the old user. Parameters: $username : The username of the user to run the code against $password : The password of the user to run the code against $code-block : The code block to run as the identified user Returns the results of the code block executed
system:clear-trace
system:clear-trace() empty()
Clear the global trace log.
system:count-instances-active
system:count-instances-active() xs:integer
Returns the number of eXist instances that are active. Returns the count
system:count-instances-available
system:count-instances-available() xs:integer
Returns the number of eXist instances that are available. Returns the count
system:count-instances-max
system:count-instances-max() xs:integer
Returns the maximum number of eXist instances. Returns the count
system:enable-tracing
system:enable-tracing($enable as xs:boolean) empty()
Enable function tracing on the database instance. Parameters: $enable : The boolean flag to enable/disable function tracing
system:enable-tracing($enable as xs:boolean, $tracelog as xs:boolean) empty()
Enable function tracing on the database instance. Parameters: $enable : The enable boolean flag to enable/disable function tracing $tracelog : The tracelog boolean flag: if set to true, entering/exiting a function will be logged to the logger 'xquery.profiling'
system:ft-index-lookup
system:ft-index-lookup($nodes as node()*, $string-filter as xs:string?) node()*
Internal function doing old full-text index lookup filtering. Intended to support the query optimizer by allowing restrictive filtering early on. Parameters: $nodes : The nodes $string-filter : The string-filter Returns the nodes matching the string-filter
system:get-build
system:get-build() xs:string
Returns the build of eXist running this query. Returns the build number
system:get-exist-home
system:get-exist-home() xs:string
Returns the eXist home location. Returns the path to the eXist home
system:get-index-statistics
system:get-index-statistics() node()?
Internal function Returns the resource containing the index statistics
system:get-memory-free
system:get-memory-free() xs:long
Returns the amount of free memory available to eXist. Returns the size of memory
system:get-memory-max
system:get-memory-max() xs:long
Returns the maximum amount of memory eXist may use. Returns the size of memory
system:get-memory-total
system:get-memory-total() xs:long
Returns the total amount of memory in use by eXist. Returns the size of memory
system:get-module-load-path
system:get-module-load-path() xs:string
Returns the module load path from the current query context. The module load path corresponds to the location on the file system from where modules are loaded into an XQuery. This is usually the directory from which the main XQuery was compiled, or - when executing a stored XQuery - the collection in which the main query resides. The module load path is also used to resolve relative XInclude paths. Returns the load path
system:get-revision
system:get-revision() xs:string
Returns the SubVersion (SVN) revision ID of eXist running this query. Returns the revision ID.
system:get-running-jobs
system:get-running-jobs() item()
Get a list of running jobs (dba role only). Returns the list of running jobs
system:get-running-xqueries
system:get-running-xqueries() item()
Get a list of running XQueries (dba role only). Returns a node containing the list of running XQueries
system:get-scheduled-jobs
system:get-scheduled-jobs() item()
Get a list of scheduled jobs (dba role only). Returns a node containing the list of scheduled jobs
system:get-version
system:get-version() xs:string
Returns the version of eXist running this query. Returns the version string
system:kill-running-xquery
system:kill-running-xquery($xquery-id as xs:integer) empty()
Kill a running XQuey (dba role only). Parameters: $xquery-id : The XQuery ID obtained from get-running-xqueries()
system:kill-running-xquery($xquery-id as xs:integer, $wait-time as xs:long) empty()
Kill a running XQuey (dba role only). Parameters: $xquery-id : The XQuery ID obtained from get-running-xqueries() $wait-time : The wait time in milliseconds before terminating the XQuery
system:restore
system:restore($dir-or-file as xs:string, $admin-pass as xs:string?, $new-admin-pass as xs:string?) node()
Restore the database or a section of the database (admin user only). Parameters: $dir-or-file : This is either a backup directory with the backup descriptor (__contents__.xml) or a backup ZIP file. $admin-pass : The password for the admin user $new-admin-pass : Set the admin password to this new password. Returns the restore results
system:shutdown
system:shutdown() empty()
Shutdown eXist immediately. This method is only available to the DBA role.
system:shutdown($delay as xs:long) empty()
Shutdown eXist. This method is only available to the DBA role. Parameters: $delay : The delay in milliseconds before eXist starts to shutdown.
system:trace
system:trace() node()
Returns function call statistics gathered by the trace log. Returns the call statistics gathered by the trace
system:tracing-enabled
system:tracing-enabled() xs:boolean
Returns true if function tracing is currently enabled on the database instance. Returns true is tracing is enabled.
system:trigger-system-task
system:trigger-system-task($java-classname as xs:string, $task-parameters as node()?) empty()
Trigger a system task. Parameters: $java-classname : The full name of the Java class to execute. It must implement org.exist.storage.SystemTask $task-parameters : The XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>
system:update-statistics
system:update-statistics() empty()
This function is part of the unfinished index statistics module, which is not yet usable in a normal eXist setup. update-statistics rebuilds index statistics for the entire database.
A module for interaction with subversion (svn) repositories. (http://exist-db.org/xquery/svn)
svn:log
svn:log($repositort-uri as xs:anyURI, $username as xs:string, $password as xs:string, $start-revision as xs:integer?, $end-revision as xs:integer?) node()*
Retrieves the log entries from a subversion repository. Parameters: $repositort-uri : The location in the subversion repository URI from which the logs should be retrieved $username : The subversion username $password : The subversion password $start-revision : The subversion revision to start from. If empty, then start from the beginning. $end-revision : The subversion revision to end with. If empty, then end with the HEAD revision Returns a sequence containing the log entriess
A module for performing SQL queries against Databases, returning XML representations of the result sets. (http://exist-db.org/xquery/sql)
sql:execute
sql:execute($handle as xs:integer, $sql-statement as xs:string, $make-node-from-column-name as xs:boolean) node()?
Executes a SQL statement against a SQL db using the connection indicated by the connection handle. Parameters: $handle : The connection handle $sql-statement : The SQL statement $make-node-from-column-name : The flag that indicates whether the xml nodes should be formed from the column names (in this mode a space in a Column Name will be replaced by an underscore!) Returns the results
sql:get-connection
sql:get-connection($driver-classname as xs:string, $url as xs:string) xs:long?
Opens a connection to a SQL Database Parameters: $driver-classname : The JDBC driver classname $url : The JDBC connection URL Returns an xs:long representing the connection handle
sql:get-connection($driver-classname as xs:string, $url as xs:string, $properties as element()?) xs:long?
Opens a connection to a SQL Database Parameters: $driver-classname : The JDBC driver classname $url : The JDBC connection URL $properties : The JDBC database connection properties in the form <properties><property name="" value=""/></properties>. Returns an xs:long representing the connection handle
sql:get-connection($driver-classname as xs:string, $url as xs:string, $username as xs:string, $password as xs:string) xs:long?
Opens a connection to a SQL Database Parameters: $driver-classname : The JDBC driver classname $url : The JDBC connection URL $username : The SQL database username $password : The SQL database password Returns an xs:long representing the connection handle
sql:get-jndi-connection
sql:get-jndi-connection($jndi-name as xs:string) xs:long?
Opens a connection to a SQL Database. Parameters: $jndi-name : The JNDI name Returns an xs:long representing the connection handle
sql:get-jndi-connection($jndi-name as xs:string, $username as xs:string, $password as xs:string) xs:long?
Opens a connection to a SQL Database. Parameters: $jndi-name : The JNDI name $username : The username $password : The password Returns an xs:long representing the connection handle
A module for dealing with the HTTP session. (http://exist-db.org/xquery/session)
session:clear
session:clear() empty()
Removes all attributes from the current HTTP session. Does NOT invalidate the session.
session:create
session:create() empty()
Initialize an HTTP session if not already present
session:encode-url
session:encode-url($url as xs:anyURI) xs:anyURI
Encodes the specified URL with the current HTTP session-id. Parameters: $url : The URL to encode Returns the encoded URL
session:exists
session:exists() xs:boolean
Returns whether a session object exists. Returns true if the session object exists
session:get-attribute
session:get-attribute($name as xs:string) xs:string*
Returns an attribute stored in the current session object or an empty sequence if the attribute cannot be found. Parameters: $name : The session attribute name Returns the attribute value
session:get-attribute-names
session:get-attribute-names() xs:string*
Returns a sequence containing the names of all session attributes defined within the current HTTP session. Returns the list of attribute names
session:get-id
session:get-id() xs:string?
Returns the ID of the current session or an empty sequence if there is no session. Returns the session ID
session:invalidate
session:invalidate() empty()
Invalidate (remove) the current HTTP session if present
session:remove-attribute
session:remove-attribute($name as xs:string) empty()
Removes the attribute with the supplied name from the current session Parameters: $name : The attribute name
session:set-attribute
session:set-attribute($name as xs:string, $value as item()*) empty()
Stores a value in the current session using the supplied attribute name. If no session exists, then one will be created. Parameters: $name : The attribute name $value : The value to be stored in the session by the attribute name
session:set-current-user
session:set-current-user($user-name as xs:string, $password as xs:string) xs:boolean?
Change the user identity for the current HTTP session. Subsequent XQueries in the session will run with the new user identity. Parameters: $user-name : The user name $password : The password Returns true if the user name and password represent a valid user
A module for scheduling jobs using the Quartz Scheduler (http://exist-db.org/xquery/scheduler)
scheduler:delete-scheduled-job
scheduler:delete-scheduled-job($job-name as xs:string) xs:boolean
Delete the named job named from the Scheduler. Will only delete User Scheduled Jobs! Returns true if the Job was deleted. Parameters: $job-name : The name of the job to be deleted Returns a boolean value indicating success or failure on deleting the named job.
scheduler:get-scheduled-jobs
scheduler:get-scheduled-jobs() node()
Gets the details of all scheduled jobs in the form: <scheduler:jobs xmlns:scheduler="http://exist-db.org/xquery/scheduler" count="iJobs"> <scheduler:group name="group"> <scheduler:job name=""> <scheduler:trigger name=""> <expression></expression> <state></state> <start></start> <end></end> <previous></previous> <next></next> <final></final> </scheduler:trigger> </scheduler:job> </scheduler:group></scheduler:jobs> Returns the XML containing the list of jobs
scheduler:pause-scheduled-job
scheduler:pause-scheduled-job($job-name as xs:string) xs:boolean
Pause the named job in the scheduler. Will only pause user scheduled jobs! Parameters: $job-name : The name of the job in the scheduler Returns the success of the pausing of the named job
scheduler:resume-scheduled-job
scheduler:resume-scheduled-job($job-name as xs:string) xs:boolean
Resumes the named job in the scheduler. Will only resume user scheduled jobs! Parameters: $job-name : The name of the job to resume. Returns the indicator of successful resumption
scheduler:schedule-java-cron-job
scheduler:schedule-java-cron-job($java-classname as xs:string, $cron-expression as xs:string, $job-name as xs:string) xs:boolean
Schedules the Java Class named (the class must extend org.exist.scheduler.UserJavaJob) according to the Cron expression. The job will be registered using the job name. Parameters: $java-classname : The full name of the class to be executed. It must extend the org.exist.scheduler.UserJavaJob class. $cron-expression : The cron expression. Please see the scheduler documentation. $job-name : The name of the job. Returns a flag indicating successful execution
scheduler:schedule-java-cron-job($java-classname as xs:string, $cron-expression as xs:string, $job-name as xs:string, $job-parameters as element()?) xs:boolean
Schedules the Java Class named (the class must extend org.exist.scheduler.UserJavaJob) according to the Cron expression. The job will be registered using the name passed in $job-name. The final argument can be used to specify parameters for the job, which will be passed to the query as external variables. Parameters are specified in an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>. Parameters: $java-classname : The full name of the class to be executed. It must extend the org.exist.scheduler.UserJavaJob class. $cron-expression : The cron expression. Please see the scheduler documentation. $job-name : The name of the job. $job-parameters : The XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters> Returns a flag indicating successful execution
scheduler:schedule-java-periodic-job
scheduler:schedule-java-periodic-job($java-classname as xs:string, $period as xs:integer, $job-name as xs:string, $job-parameters as element()?, $delay as xs:integer, $repeat as xs:integer) xs:boolean
Schedules the Java Class named (the class must extend org.exist.scheduler.UserJavaJob) according to the periodic value. The job will be registered using the job name. The $job-parameters argument can be used to specify parameters for the job, which will be passed to the query as external variables. Parameters are specified in an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>, Given the delay and the repeat. Parameters: $java-classname : The full name of the class to be executed. It must extend the org.exist.scheduler.UserJavaJob class. $period : Time in milliseconds between execution of the job $job-name : The name of the job. $job-parameters : The XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters> $delay : The period in milliseconds to delay the start of a job. $repeat : The number of times to repeat the job after the initial execution Returns a flag indicating successful execution
scheduler:schedule-xquery-cron-job
scheduler:schedule-xquery-cron-job($xquery-resource as xs:string, $cron-expression as xs:string, $job-name as xs:string) xs:boolean
Schedules the named XQuery resource (e.g. /db/foo.xql) according to the Cron expression. XQuery job's will be launched under the guest account initially, although the running XQuery may switch permissions through calls to xmldb:login(). The job will be registered using the job name. Parameters: $xquery-resource : The path to the XQuery resource $cron-expression : The cron expression. Please see the scheduler documentation. $job-name : The name of the job. Returns a flag indicating successful execution
scheduler:schedule-xquery-cron-job($xquery-resource as xs:string, $cron-expression as xs:string, $job-name as xs:string, $job-parameters as element()?) xs:boolean
Schedules the named XQuery resource (e.g. /db/foo.xql) according to the Cron expression. XQuery job's will be launched under the guest account initially, although the running XQuery may switch permissions through calls to xmldb:login(). The job will be registered using the job name. The final argument can be used to specify parameters for the job, which will be passed to the query as external variables. Parameters are specified in an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters> Parameters: $xquery-resource : The path to the XQuery resource $cron-expression : A cron expression. Please see the scheduler documentation. $job-name : The name of the job. $job-parameters : XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters> Returns Flag indicating successful execution
scheduler:schedule-xquery-periodic-job
scheduler:schedule-xquery-periodic-job($xquery-resource as xs:string, $period as xs:integer, $job-name as xs:string, $job-parameters as element()?, $delay as xs:integer, $repeat as xs:integer) xs:boolean
Schedules the named XQuery resource (e.g. /db/foo.xql) according to the period. XQuery job's will be launched under the guest account initially, although the running XQuery may switch permissions through calls to xmldb:login(). The job will be registered using the job name. The job parameters argument can be used to specify parameters for the job, which will be passed to the query as external variables. Parameters are specified in an XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>, Given the delay passed and the repeat value. Parameters: $xquery-resource : The path to the XQuery resource $period : Time in milliseconds between execution of the job $job-name : The name of the job. $job-parameters : XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters> $delay : Can be used with a period in milliseconds to delay the start of a job. $repeat : Number of times to repeat the job after the initial execution Returns Flag indicating successful execution
A module for dealing with HTTP responses. (http://exist-db.org/xquery/response)
response:exists
response:exists() xs:boolean
Returns whether a response object exists. Returns true if the response object exists
response:redirect-to
response:redirect-to($uri as xs:anyURI) empty()
Sends a HTTP redirect response (302) to the client. Note: this is not supported by the Cocooon generator. Use a sitemap redirect instead. Parameters: $uri : The URI to redirect the client to
response:set-cookie
response:set-cookie($name as xs:string, $value as xs:string) empty()
Sets a HTTP Cookie on the HTTP Response. Parameters: $name : The cookie name $value : The cookie value
response:set-cookie($name as xs:string, $value as xs:string, $max-age as xs:duration, $name as xs:boolean?) empty()
Sets a HTTP Cookie on the HTTP Response. Parameters: $name : The cookie name $value : The cookie value $max-age : The xs:duration of the cookie $name : The flag on whether the cookie is to be secure (eg. only transferred using HTTPS)
response:set-header
response:set-header($name as xs:string, $value as xs:string) empty()
Sets a HTTP Header on the HTTP Response. Parameters: $name : The header name $value : The header value
response:set-status-code
response:set-status-code($code as xs:integer) empty()
Sets a HTTP server status code on the HTTP Response. Parameters: $code : The status code
response:stream-binary
response:stream-binary($binary-data as xs:base64Binary, $content-type as xs:string, $filename as xs:string?, ...) empty()
Streams the binary data to the current servlet response output stream. The ContentType HTTP header is set to the value given in $content-type.This function only works within a servlet context, not within Cocoon. Note: the servlet output stream will be closed afterwards and mime-type settings in the prolog will not be passed. Parameters: $binary-data : The binary data to stream $content-type : The ContentType HTTP header value $filename : The filename. If no filename is given, then the current request name is used
A module for dealing with HTTP requests. (http://exist-db.org/xquery/request)
request:attribute-names
request:attribute-names() xs:string*
Returns the names of all request attributes in the current request. Returns the names of all attributes attached to the current request
request:exists
request:exists() xs:boolean
Returns whether a request object exists. Returns true if the request object exists
request:get-attribute
request:get-attribute($attribute-name as xs:string) item()*
Returns the string value of the request attribute specified in the argument or the empty sequence if no such attribute exists. The attribute value should be a string. Parameters: $attribute-name : The name of the attribute Returns the string value of the requested attribute
request:get-context-path
request:get-context-path() xs:string
Returns the context path of the current request, i.e. the portion of the request URI that indicates the context of the request. Returns the context path of the current request
request:get-cookie-names
request:get-cookie-names() xs:string*
Returns the names of all Cookies in the request Returns a sequence of the names of all Cookies in the request
request:get-cookie-value
request:get-cookie-value($cookie-name as xs:string) xs:string?
Returns the value of a named Cookie. Parameters: $cookie-name : The name of the cookie to retrieve the value from. Returns the value of the named Cookie
request:get-data
request:get-data() item()?
Returns the content of a POST request.If its a binary document xs:base64Binary is returned or if its an XML document a node() is returned. All other data is returned as an xs:string representaion. Returns an empty sequence if there is no data. Returns the content of a POST request
request:get-effective-uri
request:get-effective-uri() xs:anyURI
Returns the URI of the current request. If the request was forwarded via URL rewriting, the function returns the effective, rewritten URI, not the original URI which was received from the client. Returns the URI of the request
request:get-header
request:get-header($header-name as xs:string) xs:string?
Returns the HTTP request header identified by $header-name. The list of all headers included in the HTTP request are available through the request:get-header-names function. Parameters: $header-name : The HTTP request header name Returns the HTTP request header value
request:get-header-names
request:get-header-names() xs:string*
Returns a sequence containing the names of all headers passed in the current request Returns a sequence containing the names of all headers passed in the current request
request:get-hostname
request:get-hostname() xs:string
Returns the hostname of the current request. Returns the hostname of the current request
request:get-method
request:get-method() xs:string
Returns the HTTP method of the current request. Returns the HTTP method of the current request
request:get-parameter
request:get-parameter($name as xs:string, $default-value as item()*) xs:string*
Returns the HTTP request parameter identified by $name. If the parameter could not be found, the default value is returned instead. Note: this function will not try to expand predefined entities like &amp; or &lt;, so a &amp; passed through a parameter will indeed be treated as an &amp; character. Parameters: $name : The parameter name $default-value : The default value if the parameter does not exist Returns the parameter value
request:get-parameter($name as xs:string, $default-value as item()*, $failonerror as xs:boolean*) xs:string*
Returns the HTTP request parameter identified by $name. If the parameter could not be found, the default value is returned instead. Note: this function will not try to expand predefined entities like &amp; or &lt;, so a &amp; passed through a parameter will indeed be treated as an &amp; character. Parameters: $name : The parameter name $default-value : The default value if the parameter does not exist $failonerror : The fail on error flag. If the value is set to false, then the function will not fail if there is no request in scope. Returns the parameter value
request:get-parameter-names
request:get-parameter-names() xs:string*
Returns a sequence containing the names of all parameters passed in the current request Returns the sequence containing the names of all parameters
request:get-path-info
request:get-path-info() xs:string
Returns any extra path information associated with the URL the client sent when it made this request. For example an xquery GET or POST to /some/path/myfile.xq/extra/path will return /extra/path when myfile.xq is executed. Returns the request path information
request:get-query-string
request:get-query-string() xs:string?
Returns the full query string passed to the servlet (without the initial question mark). Returns the query string
request:get-remote-addr
request:get-remote-addr() xs:string
Returns the IP address of the client machine that made the current request, as a string. Returns the IP address
request:get-remote-host
request:get-remote-host() xs:string
Returns the fully qualified name of the client or the last proxy that sent the current request. Returns the host name
request:get-remote-port
request:get-remote-port() xs:integer
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the current request. Returns the IP port number
request:get-server-name
request:get-server-name() xs:string
Returns the server nodename of the current request. Returns the server nodename of the current request
request:get-server-port
request:get-server-port() xs:integer
Returns the server port of the current request. Returns the server port of the current request
request:get-servlet-path
request:get-servlet-path() xs:string
Returns the servlet path of the current request, i.e. the portion of the request URI that points to the servlet which is handling the request. For example an xquery GET or POST to /some/path/myfile.xq/extra/path will return /some/path/myfile.xq when myfile.xq is executed. Returns the servlet path of the current request
request:get-uploaded-file
request:get-uploaded-file($upload-param-name as xs:string) item()?
Retrieve the Java file object where the file part of a multi-part request has been stored. Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part. Parameters: $upload-param-name : The parameter name
request:get-uploaded-file-data
request:get-uploaded-file-data($upload-param-name as xs:string) xs:base64Binary?
Retrieve the base64 encoded data where the file part of a multi-part request has been stored. Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part. Parameters: $upload-param-name : The parameter name Returns the base64 encoded data from the uploaded file
request:get-uploaded-file-name
request:get-uploaded-file-name($upload-param-name as xs:string) xs:string?
Retrieve the file name of an uploaded file from a multi-part request. This returns the file name of the file on the client (without path). Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part. Parameters: $upload-param-name : The parameter name Returns the file name of the uploaded file
request:get-uploaded-file-size
request:get-uploaded-file-size($upload-param-name as xs:string) xs:double?
Retrieve the size of an uploaded file from a multi-part request. This returns the size of the file in bytes. Returns the empty sequence if the request is not a multi-part request or the parameter name does not point to a file part. Parameters: $upload-param-name : The parameter name Returns the size of the uploaded file
request:get-uri
request:get-uri() xs:anyURI
Returns the URI of the current request. This will be the original URI as received from the client. Possible modifications done by the URL rewriter will not be visible. Returns the URI of the request
request:get-url
request:get-url() xs:string
Returns the URL of the current request. Returns the URL of the current request
request:set-attribute
request:set-attribute($name as xs:string, $value as item()*) empty()
Stores a value in the current request using the supplied attribute name. Parameters: $name : The attribute name $value : The attribute value
A module for NGram-based indexed searching. (http://exist-db.org/xquery/ngram)
ngram:contains
ngram:contains($nodes as node()*, $queryString as xs:string?) node()*
Similar to the standard XQuery fn:contains function, but based on the NGram index. Searches the given $queryString in the index defined on the input node set $nodes. The string may appear at any position within the node content. String comparison is case insensitive. Nodes need to have an ngram index to be searched. Parameters: $nodes : The input node set to search $queryString : The exact string to search for Returns a set of nodes from the input node set $nodes containing the query string or the empty sequence
ngram:ends-with
ngram:ends-with($nodes as node()*, $queryString as xs:string?) node()*
Similar to the standard XQuery fn:ends-with function, but based on the NGram index. Searches the given $queryString in the index defined on the input node set $nodes. The string has to appear at the end of the node's content. String comparison is case insensitive. Nodes need to have an ngram index to be searched. Parameters: $nodes : The input node set to search $queryString : The exact string to search for Returns a set of nodes from the input node set $nodes ending with the query string or the empty sequence
ngram:filter-matches
ngram:filter-matches($nodes as node()*, $function-reference as function) node()*
Highlight matching strings within text nodes that resulted from a ngram search. The function takes a sequence of nodes as first argument $nodes and a callback function (defined with util:function) as second parameter $function-reference. Each node in $nodes will be copied into a new document fragment. For each ngram match found while copying a node, the callback function in $function-reference will be called once. The callback function should take 2 arguments: 1) the matching text string as xs:string, 2) the node to which this text string belongs. The callback function should return zero or more nodes, which will be inserted into the resulting node set at the place where the matching text sequence occurred. Note: a ngram match on mixed content may span multiple nodes. In this case, the callback function is called once for every text node which is part of the matching text sequence. Parameters: $nodes : The sequence of nodes $function-reference : The callback function Returns a resulting node set
ngram:starts-with
ngram:starts-with($nodes as node()*, $queryString as xs:string?) node()*
Similar to the standard XQuery fn:starts-with function, but based on the NGram index. Searches the given $queryString in the index defined on the input node set $nodes. The string may appear at any position within the node content. String comparison is case insensitive. Nodes need to have an ngram index to be searched. Parameters: $nodes : The input node set to search $queryString : The exact string to search for Returns a set of nodes from the input node set $nodes starting with the query string or the empty sequence
A module for accessing the metadata for the dynamic context. (http://exist-db.org/xquery/metadata)
metadata:metadata
metadata:metadata() node()?
Retrieves metadata for the dynamic context. If the context item is undefined an error is raised. Returns the metadata documents
A module containing functions for common mathematical operations. (http://exist-db.org/xquery/math)
abs
abs($number as numeric?) numeric
Returns the absolute value of the argument $number. If the argument is negative returns -$number otherwise returns $number. Parameters: $number : The number Returns the absolute value of the argument
acos
asin
atan
atan2
ceil
cos
degrees
e
exp
floor
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. Parameters: $number : The number Returns the largets number without fraction part not greater than the value of $number
log
pi
power
radians
random
round
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. Parameters: $arg : The input number Returns the rounded value
sin
sqrt
tan
A module for performing email related functions (http://exist-db.org/xquery/mail)
mail:close-mail-folder
mail:close-mail-folder($mail-folder-handle as xs:integer, $expunge as xs:boolean) empty()
Closes a mail folder. Parameters: $mail-folder-handle : The mail folder handle retrieved from mail:get-mail-folder() $expunge : A boolean that specifies whether to expunge the folder on close.
mail:close-mail-store
mail:close-mail-store($mail-store-handle as xs:integer) empty()
Closes a mail store. Parameters: $mail-store-handle : The mail store handle retrieved from mail:get-mail-store()
mail:close-message-list
mail:close-message-list($message-list-handle as xs:integer) empty()
Closes a message list. Parameters: $message-list-handle : The message list handle retrieved from mail:get-message-list() or mail:search-message-list()
mail:get-mail-folder
mail:get-mail-folder($mail-store-handle as xs:integer, $foldername as xs:string) xs:long?
Opens a mail folder. Parameters: $mail-store-handle : The mail store handle retrieved from mail:get-mail-store() $foldername : The name of the folder to open Returns an xs:long representing the folder handle.
mail:get-mail-session
mail:get-mail-session($properties as element()?) xs:long?
Open's a JavaMail session. Parameters: $properties : An optional JavaMail session properties in the form <properties><property name="" value=""/></properties>. The JavaMail properties are spelled out in Appendix A of the JavaMail specifications. Returns an xs:long representing the session handle.
mail:get-mail-store
mail:get-mail-store($mail-handle as xs:integer) xs:long?
Opens a mail store. Host/User/Password/Protocol values will be obtained from the session. Parameters: $mail-handle : The JavaMail session handle retrieved from mail:get-mail-session() Returns an xs:long representing the store handle.
mail:get-message-list
mail:get-message-list($mail-folder-handle as xs:integer) xs:long?
Returns a message list of all messages in a folder. Parameters: $mail-folder-handle : The mail folder handle retrieved from mail:get-mail-folder() Returns an xs:long representing the message list handle.
mail:get-message-list-as-xml
mail:get-message-list-as-xml($message-list-handle as xs:integer, $include-headers as xs:boolean) element()?
Returns a message list of all messages in a folder as XML. If there are no messages in the list, an empty sequence will be returned Parameters: $message-list-handle : The message list handle retrieved from mail:get-message-list() or mail:search-message-list() $include-headers : A boolean specifying whether to include message headers Returns the list of all messages in a folder as XML
mail:search-message-list
mail:search-message-list($mail-folder-handle as xs:integer, $search-parameters as element()) xs:long?
Searches messages in a folder. Search terms are of the form <searchTerm type="xxx">...</searchTerm>. Valid types include: not, and, or, from, subject, body, recipient, header, flag, sent, received. <searchTerm type="not"> requires a single nested child search term. <searchTerm type="and"> and <searchTerm type="or"> must have one or more nested child search terms. <searchTerm type="from" pattern="pat">, <searchTerm type="subject" pattern="pat"> and <searchTerm type="body" pattern="pat"> require a pattern attribute and will search for a substring that matches the pattern. <searchTerm type="recipient" pattern="pat" recipientType="to|cc|bcc"> requires pattern and recipientType attributes. <searchTerm type="header" pattern="pat" name="Content-Type"> requires pattern and name attributes. <searchTerm type="flag" flag="answered|deleted|draft|recent|seen" value="true|false"> requires flag and value attributes. <searchTerm type="sent" comparison="eq|gt|ge|lt|le|ne" format="format" date="date"> and <searchTerm type="received" comparison="eq|gt|ge|lt|le|ne" format="format" date="date"> require comparison, format and date attributes. The format string should conform to Java SimpleDateFormat specifications and the date string must conform to the specified format string. Parameters: $mail-folder-handle : The mail folder handle retrieved from mail:get-mail-folder() $search-parameters : The xml fragment defining the search terms Returns an xs:long representing the message list handle.
mail:send-email
mail:send-email($email as element()+, $server as xs:string?, $charset as xs:string?) xs:boolean+
Sends an email through the SMTP Server. Parameters: $email : The email message in the following format: <mail> <from/> <reply-to/> <to/> <cc/> <bcc/> <subject/> <message> <text/> <xhtml/> </message> <attachment filename="" mimetype="">xs:base64Binary</attachment> </mail>. $server : The SMTP server. If empty, then it tries to use the local sendmail program. $charset : The charset value used in the "Content-Type" message header (Defaults to UTF-8) Returns true if the email message was successfully sent
A module for full text indexed searching based on Lucene. (http://exist-db.org/xquery/lucene)
ft:query
ft:query($nodes as node()*, $query as item()) node()*
Queries a node set using a Lucene full text index; a lucene index must already be defined on the nodes, because if no index is available on a node, nothing will be found. Indexes on descendant nodes are not used. The context of the Lucene query is determined by the given input node set. The query is specified either as a query string based on Lucene's default query syntax or as an XML fragment. See http://exist-db.org/lucene.html#N1029E for complete documentation. Parameters: $nodes : The node set to search using a Lucene full text index which is defined on those nodes $query : The query to search for, provided either as a string or text in Lucene's default query syntax or as an XML fragment to bypass Lucene's default query parser Returns all nodes from the input node set matching the query. match highlighting information will be available for all returned nodes. Lucene's match score can be retrieved via the ft:score function.
ft:score
ft:score($node as node()) xs:float*
Returns a computed relevance score for the given node. The score is the sum of all relevance scores provided by Lucene for the node and its descendants. In general, the score will be a number between 0.0 and 1.0 if the query had $node as context. If the query targeted multiple descendants of $node (e.g. 'title' and 'author' within a 'book'), the score will be the sum of all sub-scores and may thus be greater than 1. Parameters: $node : the context node Returns sum of all relevance scores provided by Lucene for all matches below the given context node
A module for performing JNDI queries against Directories, returning XML representations of the results. (http://exist-db.org/xquery/jndi)
jndi:close-context
jndi:close-context($directory-context as xs:integer) empty()
Closes a JNDI Context Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call
jndi:create
jndi:create($directory-context as xs:integer, $dn as xs:string, $attributes as element()) empty()
Create a JNDI Directory entry. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $dn : The Distinguished Name $attributes : The entry attributes to be set in the form <attributes><attribute name="" value=""/></attributes>. You can also optionally specify ordered="true" for an attribute.
jndi:delete
jndi:delete($directory-context as xs:integer, $dn as xs:string) empty()
Delete a JNDI Directory entry. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $dn : The Distinguished Name
jndi:get-dir-context
jndi:get-dir-context($properties as element()?) xs:long?
Opens a JNDI Directory Context. Parameters: $properties : The JNDI Directory Context environment properties to be set in the form <properties><property name="" value=""/></properties>. Returns the directory context handle
jndi:modify
jndi:modify($directory-context as xs:integer, $dn as xs:string, $attributes as element()) empty()
Modify a JNDI Directory entry. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $dn : The Distinguished Name $attributes : The entry attributes to be set in the form <attributes><attribute name="" value="" operation="add | replace | remove"/></attributes>. You can also optionally specify ordered="true" for an attribute.
jndi:rename
jndi:rename($directory-context as xs:integer, $old-dn as xs:string, $new-dn as xs:string) empty()
Rename a JNDI Directory entry. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $old-dn : The Distinguished Name to rename $new-dn : The new Distinguished Name
jndi:search
jndi:search($directory-context as xs:integer, $dn as xs:string, $search-attributes as element()) node()?
Searches a JNDI Directory by attributes. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $dn : The Distinguished Name $search-attributes : The search attributes in the form <attributes><attribute name="" value=""/></attributes>. Returns the search results in DSML format
jndi:search($directory-context as xs:integer, $dn as xs:string, $filter as xs:string, $scope as xs:string) node()?
Searches a JNDI Directory by filter. Parameters: $directory-context : The directory context handle from a jndi:get-dir-context() call $dn : The Distinguished Name $filter : The filter. The format and interpretation of filter follows RFC 2254 with the following interpretations for 'attr' and 'value' mentioned in the RFC. 'attr' is the attribute's identifier. 'value' is the string represention the attribute's value. The translation of this string representation into the attribute's value is directory-specific. $scope : The scope, which has a value of 'object', 'onelevel' or 'subtree' Returns the search results in DSML format
A module for generating charts using the JFreeChart library. (http://exist-db.org/xquery/jfreechart)
jfreechart:render
jfreechart:render($chart-type as xs:string, $configuration as node(), $data as node()) xs:base64Binary?
Render chart using JFreechart. Check documentation on http://www.jfree.org/jfreechart/ for details about chart types, parameters and data structures. Parameters: $chart-type : The type of chart to render. Supported chart types: LineChart, LineChart3D, MultiplePieChart, MultiplePieChart3D, PieChart, PieChart3D, RingChart, StackedAreaChart, StackedBarChart, StackedBarChart3D, WaterfallChart. $configuration : The configuration for the chart. The configuration should be supplied as follows: <configuration><param1>Value1</param1><param2>Value2</param2>/<configuration>. Supported parameters: width height title categoryAxisLabel valueAxisLabel domainAxisLabel rangeAxisLabel orientation order legend tooltips urls. $data : The CategoryDataset or PieDataset, supplied as JFreechart XML. Returns the generated PNG image file
jfreechart:stream-render
jfreechart:stream-render($chart-type as xs:string, $configuration as node(), $data as node()) empty()
Render chart using JFreechart. Check documentation on http://www.jfree.org/jfreechart/ for details about chart types, parameters and data structures. Output is directly streamed into the servlet output stream. Parameters: $chart-type : The type of chart to render. Supported chart types: LineChart, LineChart3D, MultiplePieChart, MultiplePieChart3D, PieChart, PieChart3D, RingChart, StackedAreaChart, StackedBarChart, StackedBarChart3D, WaterfallChart. $configuration : The configuration for the chart. The configuration should be supplied as follows: <configuration><param1>Value1</param1><param2>Value2</param2>/<configuration>. Supported parameters: width height title categoryAxisLabel valueAxisLabel domainAxisLabel rangeAxisLabel orientation order legend tooltips urls. $data : The CategoryDataset or PieDataset, supplied as JFreechart XML.
A module for performing operations on Images stored in the eXist db (http://exist-db.org/xquery/image)
image:get-height
image:get-height($image as xs:base64Binary) xs:integer?
Gets the Height of the image passed in, returning an integer of the images Height in pixels or an empty sequence if the image is invalid. Parameters: $image : The image data Returns the height in pixels
image:get-metadata
image:get-metadata($image as xs:base64Binary, $native-format as xs:boolean) node()?
Gets the metadta of the image passed in, returning the images XML metadata. Parameters: $image : The image data $native-format : When true metadata of the images native format is returned, otherwise common java ImageIO metadata is returned. Returns the image metadata
image:get-width
image:get-width($image as xs:base64Binary) xs:integer?
Gets the width of the image passed in, returning an integer of the images width in pixels or an empty sequence if the image is invalid. Parameters: $image : The image data Returns the width in pixels
image:scale
image:scale($image as xs:base64Binary, $dimension as xs:integer*, $mimeType as xs:string) xs:base64Binary?
Scale the image image to a specified dimension. If no dimensions are specified, then the default values are 'maxheight = 100' and 'maxwidth = 100'. Parameters: $image : The image data $dimension : The maximum dimension of the scaled image. expressed in pixels (maxheight, maxwidth). If empty, then the default values are 'maxheight = 100' and 'maxwidth = 100'. $mimeType : The mime-type of the image Returns the scaled image or an empty sequence if $image is invalid
image:thumbnail
image:thumbnail($collection as xs:anyURI, $thumbnail-location as xs:anyURI?, $dimension as xs:integer*, $prefix as xs:string?) xs:string*
Generate thumbnails from the given database collection Parameters: $collection : The URI to the collection $thumbnail-location : The location in the database where the thumbnails should be created, this can be a local path, with the prefix 'xmldb:' a absolute path within the database or with 'rel:' path relative to the given $collection. You can leave this empty then the default is 'rel:/thumbs'. $dimension : The dimension of the thumbnails, if empty then the default values are 'maxheight = 100' and 'maxwidth = 100', the first value is 'maxheight' and the second 'maxwidth'. $prefix : The prefix to append to the thumbnail filenames Returns the result
A module for performing HTTP requests as a client (http://exist-db.org/xquery/httpclient)
httpclient:clear-persistent-cookies
httpclient:clear-persistent-cookies() empty()
Clears any persistent cookies stored in the current session on the client.
httpclient:delete
httpclient:delete($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP DELETE request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. Parameters: $url : The URL to process $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:get
httpclient:get($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP GET request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. Parameters: $url : The URL to process $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:head
httpclient:head($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP HEAD request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response> Parameters: $url : The URL to process $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:options
httpclient:options($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP OPTIONS request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response> Parameters: $url : The URL to process $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:post
httpclient:post($url as xs:anyURI, $content as item(), $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP POST request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. Parameters: $url : The URL to process $content : The XML POST payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string. $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:post-form
httpclient:post-form($url as xs:anyURI, $content as element(), $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP POST request for a form. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. Parameters: $url : The URL to process $content : The form data in the format <httpclient:fields><httpclient:field name="" value="" type="string|file"/>...</httpclient:fields>. If the field values will be suitably URLEncoded and sent with the mime type application/x-www-form-urlencoded. $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
httpclient:put
httpclient:put($url as xs:anyURI, $content as node(), $persist as xs:boolean, $request-headers as element()?) item()
Performs a HTTP PUT request.. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. Parameters: $url : The URL to process $content : The XML PUT payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string. $persist : The to indicate if the cookies persist for the query lifetime $request-headers : Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content
A module for performing various operations on files and directories stored in the server file system. (http://exist-db.org/xquery/file)
file:delete
file:delete($filepath as item()) xs:boolean
Delete a file. This method is only available to the DBA role. Parameters: $filepath : The full path to the file Returns true if successful, false otherwise
file:directory-list
file:directory-list($directory as xs:string, $pattern as xs:string) node()?
List all files, including their file size and modification time, found in or below a directory, $directory. Files are located in the server's file system, using filename patterns, $pattern. File pattern matching is based on code from Apache's Ant, thus following the same conventions. For example: '*.xml' matches any file ending with .xml in the current directory, - '**/*.xml' matches files in any directory below the specified directory. This method is only available to the DBA role. Parameters: $directory : The base directory path in the file system where the files are located. $pattern : The file name pattern Returns a node fragment that shows all matching filenames, including their file size and modification time, and the subdirectory they were found in
file:exists
file:exists($filepath as item()) xs:boolean
Tests if a file exists. This method is only available to the DBA role. Parameters: $filepath : The full path to the file in the file system Returns the boolean value true if the file exists, false otherwise
file:is-directory
file:is-directory($path as item()) xs:boolean
Tests if a path is a directory. This method is only available to the DBA role. Parameters: $path : The full path to the file or directory Returns true if the path is a directory
file:is-readable
file:is-readable($filepath as item()) xs:boolean
Tests if a file is readable. This method is only available to the DBA role. Parameters: $filepath : The full path to the file Returns true if file can be read
file:is-writeable
file:is-writeable($filepath as item()) xs:boolean
Tests if a file is writeable. This method is only available to the DBA role. Parameters: $filepath : The full path to the file Returns true if the file has write permissions
file:read
file:read($url as item()) xs:string?
Reads the content of file. This method is only available to the DBA role. Parameters: $url : A string representing a URL, eg file://etc. Returns the file contents
file:read($url as item(), $encoding as xs:string) xs:string?
Reads the content of file. This method is only available to the DBA role. Parameters: $url : A string representing a URL, eg file://etc. $encoding : The encoding type for the file Returns the file contents
file:read-binary
file:read-binary($url as item()) xs:base64Binary?
Reads the contents of a binary file. This method is only available to the DBA role. Parameters: $url : A string representing a URL, eg file://etc. Returns the file contents
file:read-unicode
file:read-unicode($url as item()) xs:string?
Reads the contents of a file. Unicode BOM (Byte Order Marker) will be stripped off if found. This method is only available to the DBA role. Parameters: $url : The URL to the file, e.g. file://etc. Returns the contents of the file
file:read-unicode($url as item(), $encoding as xs:string) xs:string?
Reads the contents of a file. Unicode BOM (Byte Order Marker) will be stripped off if found. This method is only available to the DBA role. Parameters: $url : The URL to the file, e.g. file://etc. $encoding : The file is read with the encoding specified. Returns the contents of the file
file:serialize
file:serialize($node-set as node()*, $filepath as xs:string, $parameters as xs:string*) xs:boolean?
Writes the node set into a file on the file system. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. This method is only available to the DBA role. Parameters: $node-set : The contents to write to the file system. $filepath : The full path to the file $parameters : The serialization parameters specified as key-value pairs Returns true on success - false if the specified file can not be created or is not writable. The empty sequence is returned if the argument sequence is empty.
file:serialize-binary
file:serialize-binary($binarydata as xs:base64Binary, $filepath as xs:string) xs:boolean
Writes binary data into a file on the file system. This method is only available to the DBA role. Parameters: $binarydata : The contents to write to the file system. $filepath : The full path to the file Returns true on success - false if the specified file can not be created or is not writable
A module for showing good examples of module usage (http://exist-db.org/xquery/examples)
example:echo
example:echo($text as xs:string*) xs:string*
A useless example function. It just echoes the input parameters. Parameters: $text : The text to echo Returns the echoed text
A module for performing date and time operations (http://exist-db.org/xquery/datetime)
datetime:count-day-in-month
datetime:count-day-in-month($weekday as xs:integer, $date as xs:date) xs:integer
Returns the count of a specific weekday in a month from the given date. For example it can tell you there are 5 Fridays in February 2008. Parameters: $weekday : The day of the week in the range of 1 to 7 where 1 = Sunday and 7 = Saturday. $date : The day that will identify the month to get the count of the number of occurrences of a given weekday Returns The number of occurrences of the weekday in the selected month.
datetime:date-for
datetime:date-for($year as xs:integer, $month as xs:integer, $week as xs:integer, $weekday as xs:integer) xs:date
Returns the date for a given set of parameters. Parameters: $year : The year of interest $month : The month of interest (1 = January, 12 = December) $week : The week in the month of interest (1 = first week, 4 or 5 = last week) $weekday : The day in the week of interest (1 = Sunday, 7 = Saturday) Returns the date generated from the parameters.
datetime:date-from-dateTime
datetime:date-from-dateTime($date-time as xs:dateTime) xs:date
Returns the xs:date portion of an xs:dateTime Parameters: $date-time : The dateTime to extract the date from. Returns the extracted date.
datetime:date-range
datetime:date-range($start-date as xs:date, $increment as xs:duration, $iterations as xs:integer) xs:date*
Generates a range of xs:date values, incremented cumulatively by a fixed duration from a start xs:date Parameters: $start-date : The date to start at. $increment : The duration increment. $iterations : The number of increments to generate. Returns the range(s)
datetime:datetime-range
datetime:datetime-range($start-date-time as xs:dateTime, $increment as xs:duration, $iterations as xs:integer) xs:dateTime*
Generates a range of xs:dateTime values, incremented cumulatively by a fixed duration from a start xs:dateTime Parameters: $start-date-time : The dateTime to start at. $increment : The duration increment. $iterations : The number of increments to generate. Returns the range(s)
datetime:day-in-week
datetime:day-in-week($date as xs:date) xs:integer
Returns the day in the week of the date. Result is in the range 1 to 7, where 1 = Sunday, 7 = Saturday. Parameters: $date : The date to extract the day in the week from. Returns the day in the week of the date in the range 1 to 7, where 1 = Sunday, 7 = Saturday.
datetime:days-in-month
datetime:days-in-month($date as xs:date) xs:integer
Returns the number of days in the month of the date. Parameters: $date : The date for extracting the number of days in the month component. Returns the number of days in the given month.
datetime:format-date
datetime:format-date($date as xs:date, $simple-date-format as xs:string) xs:string
Returns a xs:string of the xs:date formatted according to the SimpleDateFormat format. Parameters: $date : The date to to be formatted. $simple-date-format : The format string according to the Java java.text.SimpleDateFormat class Returns the formatted date string
datetime:format-dateTime
datetime:format-dateTime($date-time as xs:dateTime, $simple-date-format as xs:string) xs:string
Returns a xs:string of the xs:dateTime according to the SimpleDateFormat format. Parameters: $date-time : The dateTime to to be formatted. $simple-date-format : The format string according to the Java java.text.SimpleDateFormat class Returns the formatted dateTime string
datetime:format-time
datetime:format-time($time as xs:time, $simple-date-format as xs:string) xs:string
Returns a xs:string of the xs:time formatted according to the SimpleDateFormat format. Parameters: $time : The time to to be formatted. $simple-date-format : The format string according to the Java java.text.SimpleDateFormat class Returns the formatted time string
datetime:time-from-dateTime
datetime:time-from-dateTime($date-time as xs:dateTime) xs:time
Returns the xs:time portion of an xs:dateTime. Parameters: $date-time : The dateTime to extract the time from. Returns the time extracted from the date-time
datetime:time-range
datetime:time-range($start-time as xs:time, $increment as xs:duration, $iterations as xs:integer) xs:time*
Generates a range of xs:time values, incremented cumulatively by a fixed duration from a start xs:time Parameters: $start-time : The time to start at. $increment : The duration increment. $iterations : The number of increments to generate. Returns the range(s)
datetime:week-in-month
datetime:week-in-month($date as xs:date) xs:integer
Returns the week in the month of the date. Parameters: $date : The date to extract the week in the month from. Returns the week in the month of the date
A module for persistent counters. (http://exist-db.org/xquery/counter)
counter:create
counter:create($counter-name as item()) xs:long?
Create a unique counter named $counter-name. Parameters: $counter-name : Name of the counter. Returns the value of the newly created counter.
counter:create($counter-name as item(), $init-value as xs:long) xs:long?
Create a unique counter named $counter-name and initialize it with value $init-value. Parameters: $counter-name : Name of the counter. $init-value : The initial value of the counter. Returns the value of the newly created counter.
counter:destroy
counter:destroy($counter-name as item()) xs:boolean?
Destroy the counter named $counter-name. Parameters: $counter-name : Name of the counter. Returns boolean value true() if removal as successful, otherwise return value false().
counter:next-value
counter:next-value($counter-name as item()) xs:long?
Increment the counter $counter-name and return its new value. Parameters: $counter-name : Name of the counter. Returns the new value of the specified counter, or -1 if the counter does not exist.
A module for compression and decompression functions (http://exist-db.org/xquery/compression)
compression:gzip
compression:gzip($data as xs:base64Binary) xs:base64Binary?
GZip's data Parameters: $data : The data to GZip
compression:tar
compression:tar($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean) xs:base64Binary*
Tars nodes, resources and collections. Parameters: $sources : The sequence of URI's and/or Entrys. If a URI points to a collection then the collection, its resources and sub-collections are zipped recursively. An Entry takes the format <entry name="filename.ext" type="collection|uri|binary|xml|text">data</entry> $use-collection-hierarchy : Indicates whether the Collection hierarchy (if any) should be preserved in the zip file.
compression:tar($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string) xs:base64Binary*
Tars nodes, resources and collections. Parameters: $sources : The sequence of URI's and/or Entrys. If a URI points to a collection then the collection, its resources and sub-collections are zipped recursively. An Entry takes the format <entry name="filename.ext" type="collection|uri|binary|xml|text">data</entry> $use-collection-hierarchy : Indicates whether the Collection hierarchy (if any) should be preserved in the zip file. $strip-prefix : This prefix is stripped from the Entrys name
compression:ungzip
compression:ungzip($gzip-data as xs:base64Binary) xs:base64Binary?
UnGZip's data Parameters: $gzip-data : The gzip data to uncompress.
compression:untar
compression:untar($tar-data as xs:base64Binary, $entry-filter as function, $entry-filter-param as xs:anyType*, $entry-data as function, $entry-data-param as xs:anyType*) item()*
UnTar all the resources/folders from the provided data by calling user defined functions to determine what and how to store the resources/folders Parameters: $tar-data : The tar file data $entry-filter : A user defined function for filtering resources from the tar file. The function takes 3 parameters e.g. user:untar-entry-filter($path as xs:string, $data-type as xs:string, $param as item()*) as xs:boolean. $type may be 'resource' or 'folder'. $param is a sequence with any additional parameters, for example a list of extracted files.If the return type is true() it indicates the entry should be processed and passed to the entry-data function, else the resource is skipped. $entry-filter-param : A sequence with an additional parameters for filtering function. $entry-data : A user defined function for storing an extracted resource from the tar file. The function takes 4 parameters e.g. user:untar-entry-data($path as xs:string, $data-type as xs:string, $data as item()?, $param as item()*). $type may be 'resource' or 'folder'. $param is a sequence with any additional parameters $entry-data-param : A sequence with an additional parameters for storing function.
compression:unzip
compression:unzip($zip-data as xs:base64Binary, $entry-filter as function, $entry-filter-param as xs:anyType*, $entry-data as function, $entry-data-param as xs:anyType*) item()*
UnZip all the resources/folders from the provided data by calling user defined functions to determine what and how to store the resources/folders Parameters: $zip-data : The zip file data $entry-filter : A user defined function for filtering resources from the zip file. The function takes 3 parameters e.g. user:unzip-entry-filter($path as xs:string, $data-type as xs:string, $param as item()*) as xs:boolean. $type may be 'resource' or 'folder'. $param is a sequence with any additional parameters, for example a list of extracted files.If the return type is true() it indicates the entry should be processed and passed to the entry-data function, else the resource is skipped. $entry-filter-param : A sequence with an additional parameters for filtering function. $entry-data : A user defined function for storing an extracted resource from the zip file. The function takes 4 parameters e.g. user:unzip-entry-data($path as xs:string, $data-type as xs:string, $data as item()?, $param as item()*). $type may be 'resource' or 'folder'. $param is a sequence with any additional parameters $entry-data-param : A sequence with an additional parameters for storing function.
compression:zip
compression:zip($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean) xs:base64Binary*
Zips nodes, resources and collections. Parameters: $sources : The sequence of URI's and/or Entrys. If a URI points to a collection then the collection, its resources and sub-collections are zipped recursively. An Entry takes the format <entry name="filename.ext" type="collection|uri|binary|xml|text">data</entry> $use-collection-hierarchy : Indicates whether the Collection hierarchy (if any) should be preserved in the zip file.
compression:zip($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string) xs:base64Binary*
Zips nodes, resources and collections. Parameters: $sources : The sequence of URI's and/or Entrys. If a URI points to a collection then the collection, its resources and sub-collections are zipped recursively. An Entry takes the format <entry name="filename.ext" type="collection|uri|binary|xml|text">data</entry> $use-collection-hierarchy : Indicates whether the Collection hierarchy (if any) should be preserved in the zip file. $strip-prefix : This prefix is stripped from the Entrys name
A module for accessing a global cache for stored/shared data between sessions (http://exist-db.org/xquery/cache)
cache:cache
cache:cache($name as xs:string) object
Get/create a cache using the specified name. Parameters: $name : The name of the cache to get/create Returns the Java cache object with the given name.
cache:clear
cache:clear() empty()
Clear the entire cache, globally
cache:clear($cache-value as item()) empty()
Clear the identified cache Parameters: $cache-value : Either the Java cache object or the name of the cache
cache:get
cache:get($cache-identity as item(), $key as xs:anyType+) xs:anyType*
Get data from identified global cache by key Parameters: $cache-identity : Either the Java cache object or the name of the cache $key : The key to the object within the cache Returns the value that is associated with the key
cache:put
cache:put($cache-value as item(), $key as xs:anyType+, $value as xs:anyType*) xs:anyType*
Put data with a key into the identified cache. Returns the previous value associated with the key Parameters: $cache-value : Either the Java cache object or the name of the cache $key : The key to the object within the cache $value : The object to store within the cache Returns the previous value associated with the key
cache:remove
cache:remove($cache-value as item(), $key as xs:anyType+) xs:anyType*
Remove data from the identified cache by the key. Returns the value that was associated with key Parameters: $cache-value : Either the Java cache object or the name of the cache $key : The key to the object within the cache Returns the value that was associated with the key
A module for access to database backups available on the server file system (http://exist-db.org/xquery/backups)
backups:list
backups:list($directory as xs:string) node()
Returns an XML fragment listing all eXist backups found in a specified backup directory. Parameters: $directory : The path to the directory to show the list of backups on. Returns an XML fragment listing all eXist backups found in the specified backup directory: <directory> <backup file="filename"> <key>value</key><key>value</key></backup> <backup file="filename"> <key>value</key><key>value</key></backup> </directory> Where key is a property name and value is a property value for the given .zip file.
backups:retrieve
backups:retrieve($directory as xs:string, $name as xs:string) empty()
Retrieves a zipped backup archive, $name, and directly streams it to the HTTP response. For security reasons, the function will only read .zip files in the specified directory, $directory. Parameters: $directory : The path to the directory where the backup file is located. $name : The name of the file to retrieve.

View source code