A RESTful browser for eXist Java-Based Function Modules


http://exist-db.org/xquery/examples
A module for showing good examples of module usage

example:echo($text as xs:string*) xs:string*
A useless example function. It just echoes the input parameters.
$textThe text to echo

Returns the echoed text

http://exist-db.org/xquery/httpclient
A module for performing HTTP requests as a client

httpclient:clear-persistent-cookies() empty()
Clears any persistent cookies stored in the current session on the client.

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.
$urlThe URL to process
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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.
$urlThe URL to process
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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>
$urlThe URL to process
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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>
$urlThe URL to process
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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.
$urlThe URL to process
$contentThe XML POST payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string.
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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.
$urlThe URL to process
$contentThe 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.
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

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.
$urlThe URL to process
$contentThe XML PUT payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string.
$persistThe to indicate if the cookies persist for the query lifetime
$request-headersAny HTTP Request Headers to set in the form <headers><header name="" value=""/></headers>

Returns the XML body content

http://exist-db.org/xquery/lucene
A module for full text indexed searching based on Lucene.

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.
$nodesThe node set to search using a Lucene full text index which is defined on those nodes
$queryThe 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($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.
$nodethe context node

Returns sum of all relevance scores provided by Lucene for all matches below the given context node

http://exist-db.org/xquery/ngram
A module for NGram-based indexed searching.

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.
$nodesThe input node set to search
$queryStringThe 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($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.
$nodesThe input node set to search
$queryStringThe 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($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.
$nodesThe sequence of nodes
$function-referenceThe callback function

Returns a resulting node set

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.
$nodesThe input node set to search
$queryStringThe 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

http://exist-db.org/xquery/request
A module for dealing with HTTP requests.

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:create-session() empty()
Initialize an HTTP session if not already present

Deprecated: Moved to the 'session' module. See session:create. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:encode-url($url as xs:anyURI) xs:anyURI
Encodes the specified URL with the current HTTP session-id.
$urlThe URL to encode

Returns the encoded URL

Deprecated: Moved to the 'session' module. See session:encode-url. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:exists() xs:boolean
Returns whether a request object exists.

Returns true if the request object exists

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.
$attribute-nameThe name of the attribute

Returns the string value of the requested attribute

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() 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($cookie-name as xs:string) xs:string?
Returns the value of a named Cookie.
$cookie-nameThe name of the cookie to retrieve the value from.

Returns the value of the named Cookie

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() 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($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.
$header-nameThe HTTP request header name

Returns the HTTP request header value

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() xs:string
Returns the hostname of the current request.

Returns the hostname of the current request

request:get-method() xs:string
Returns the HTTP method of the current request.

Returns the HTTP method of the current request

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.
$nameThe parameter name
$default-valueThe 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.
$nameThe parameter name
$default-valueThe default value if the parameter does not exist
$failonerrorThe 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() 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() 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() xs:string?
Returns the full query string passed to the servlet (without the initial question mark).

Returns the query string

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() 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() 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-request-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

Deprecated: Renamed to get-data. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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() xs:integer
Returns the server port of the current request.

Returns the server port of the current request

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-session-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.
$nameThe session attribute name

Returns the attribute value

Deprecated: Moved to 'session' module. Renamed to session:get-attribute This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:get-session-id() xs:string?
Returns the ID of the current session or an empty sequence if there is no session.

Returns the session ID

Deprecated: Moved to session module and renamed to session:get-id. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$upload-param-nameThe parameter name

Deprecated: Deprecated in favour of get-uploaded-file-data() This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$upload-param-nameThe parameter name

Returns the base64 encoded data from the uploaded file

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.
$upload-param-nameThe parameter name

Returns the file name of the uploaded file

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.
$upload-param-nameThe parameter name

Returns the size of the uploaded file

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() xs:string
Returns the URL of the current request.

Returns the URL of the current request

request:invalidate-session() empty()
Invalidate (remove) the current HTTP session if present

Deprecated: Moved to 'session' module and renamed to session:invalidate This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request: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: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.
$uriThe URI to redirect the client to

Deprecated: Moved to 'response' module. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-hostname() xs:string
Returns the hostname of the current request.

Returns the hostname of the current request

Deprecated: Renamed to request:get-hostname. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-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.
$nameThe parameter name
$default-valueThe default value if the parameter does not exist

Returns the parameter value

Deprecated: Renamed to request:get-parameter. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-servername() xs:string
Returns the server nodename of the current request.

Returns the server nodename of the current request

Deprecated: Renamed to request:get-server-name. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-serverport() xs:integer
Returns the server port of the current request.

Returns the server port of the current request

Deprecated: Renamed to request:get-server-port. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:request-uri() xs:anyURI
Returns the URI of the current request.

Returns the URI of the request

Deprecated: Renamed to request:get-uri. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:session-attributes() xs:string*
Returns a sequence containing the names of all session attributes defined within the current HTTP session.

Returns the list of attribute names

Deprecated: Moved to session module and renamed to session:get-attribute-names. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:set-attribute($name as xs:string, $value as item()*) empty()
Stores a value in the current request using the supplied attribute name.
$nameThe attribute name
$valueThe attribute value

request: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.
$user-nameThe user name
$passwordThe password

Returns true if the user name and password represent a valid user

Deprecated: Moved to session module. See session:set-current-user. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request:stream-binary($binary-data as xs:base64Binary, $content-type 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.
$binary-dataThe binary data to stream
$content-typeThe ContentType HTTP header value

Deprecated: Renamed to response:stream-binary. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

request: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()
$escaped-stringThe escaped string to be un-escaped
$encodingThe encoding scheme to use in the un-escaping of the string

Returns the un-escaped string

Deprecated: Moved to the util module. See util:unescape-uri. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

http://exist-db.org/xquery/response
A module for dealing with HTTP responses.

response:exists() xs:boolean
Returns whether a response object exists.

Returns true if the response object exists

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.
$uriThe URI to redirect the client to

response:set-cookie($name as xs:string, $value as xs:string) empty()
Sets a HTTP Cookie on the HTTP Response.
$nameThe cookie name
$valueThe 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.
$nameThe cookie name
$valueThe cookie value
$max-ageThe xs:duration of the cookie
$nameThe flag on whether the cookie is to be secure (eg. only transferred using HTTPS)

response:set-header($name as xs:string, $value as xs:string) empty()
Sets a HTTP Header on the HTTP Response.
$nameThe header name
$valueThe header value

response:set-status-code($code as xs:integer) empty()
Sets a HTTP server status code on the HTTP Response.
$codeThe status code

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.
$binary-dataThe binary data to stream
$content-typeThe ContentType HTTP header value
$filenameThe filename. If no filename is given, then the current request name is used

http://exist-db.org/xquery/session
A module for dealing with the HTTP session.

session:clear() empty()
Removes all attributes from the current HTTP session. Does NOT invalidate the session.

session:create() empty()
Initialize an HTTP session if not already present

session:encode-url($url as xs:anyURI) xs:anyURI
Encodes the specified URL with the current HTTP session-id.
$urlThe URL to encode

Returns the encoded URL

session:exists() xs:boolean
Returns whether a session object exists.

Returns true if the session object exists

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.
$nameThe session attribute name

Returns the attribute value

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() xs:string?
Returns the ID of the current session or an empty sequence if there is no session.

Returns the session ID

session:invalidate() empty()
Invalidate (remove) the current HTTP session if present

session:remove-attribute($name as xs:string) empty()
Removes the attribute with the supplied name from the current session
$nameThe attribute name

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.
$nameThe attribute name
$valueThe value to be stored in the session by the attribute name

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.
$user-nameThe user name
$passwordThe password

Returns true if the user name and password represent a valid user

http://exist-db.org/xquery/system
A module for retrieving information about eXist and the system.

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.
$usernameThe username of the user to run the code against
$passwordThe password of the user to run the code against
$code-blockThe code block to run as the identified user

Returns the results of the code block executed

system:clear-trace() empty()
Clear the global trace log.

system:count-instances-active() xs:integer
Returns the number of eXist instances that are active.

Returns the count

system:count-instances-available() xs:integer
Returns the number of eXist instances that are available.

Returns the count

system:count-instances-max() xs:integer
Returns the maximum number of eXist instances.

Returns the count

system:enable-tracing($enable as xs:boolean) empty()
Enable function tracing on the database instance.
$enableThe 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.
$enableThe enable boolean flag to enable/disable function tracing
$tracelogThe tracelog boolean flag: if set to true, entering/exiting a function will be logged to the logger 'xquery.profiling'

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.
$nodesThe nodes
$string-filterThe string-filter

Returns the nodes matching the string-filter

system:get-build() xs:string
Returns the build of eXist running this query.

Returns the build number

system:get-exist-home() xs:string
Returns the eXist home location.

Returns the path to the eXist home

system:get-index-statistics() node()?
Internal function

Returns the resource containing the index statistics

system:get-memory-free() xs:long
Returns the amount of free memory available to eXist.

Returns the size of memory

system:get-memory-max() xs:long
Returns the maximum amount of memory eXist may use.

Returns the size of memory

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() 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() xs:string
Returns the SubVersion (SVN) revision ID of eXist running this query.

Returns the revision ID.

system:get-running-jobs() item()
Get a list of running jobs (dba role only).

Returns the list of running jobs

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() item()
Get a list of scheduled jobs (dba role only).

Returns a node containing the list of scheduled jobs

system:get-version() xs:string
Returns the version of eXist running this query.

Returns the version string

system:kill-running-xquery($xquery-id as xs:integer) empty()
Kill a running XQuey (dba role only).
$xquery-idThe 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).
$xquery-idThe XQuery ID obtained from get-running-xqueries()
$wait-timeThe wait time in milliseconds before terminating the XQuery

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).
$dir-or-fileThis is either a backup directory with the backup descriptor (__contents__.xml) or a backup ZIP file.
$admin-passThe password for the admin user
$new-admin-passSet the admin password to this new password.

Returns the restore results

system:shutdown($delay as xs:long) empty()
Shutdown eXist. This method is only available to the DBA role.
$delayThe delay in milliseconds before eXist starts to shutdown.

system:shutdown() empty()
Shutdown eXist immediately. This method is only available to the DBA role.

system:trace() node()
Returns function call statistics gathered by the trace log.

Returns the call statistics gathered by the trace

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($java-classname as xs:string, $task-parameters as node()?) empty()
Trigger a system task.
$java-classnameThe full name of the Java class to execute. It must implement org.exist.storage.SystemTask
$task-parametersThe XML fragment with the following structure: <parameters><param name="param-name1" value="param-value1"/></parameters>

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.

http://exist-db.org/xquery/text
A module for text searching extension functions.

text:filter($text as xs:string, $regularexpression as xs:string) xs:string*
Filter substrings that match the regular expression in the text.
$textThe text to filter
$regularexpressionThe regular expression to perform against the text

Returns the substrings

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.
$node-setThe node set

Returns a node set containing nodes that do not have descendent nodes.

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.
$termThe term

Returns a sequence of strings which are similar to the argument $term

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.
$sourceThe source
$keywordThe keyword string

Returns the sequence of nodes that match the keywords

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.
$sourceThe source
$keywordThe keyword string

Returns the sequence of nodes that match the keywords

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.
$textThe text to filter
$regularexpressionThe 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.
$textThe text to filter
$regularexpressionThe regular expression to perform against the text
$flagsThe 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($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>.
$sourceThe sequence of text nodes
$callback-function-refThe callback function (defined with util:function)
$parametersThe sequence of additional values that will be passed to the callback functions third parameter.

Returns the source with the added highlights

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.
$nodesThe set of nodes in which the returned tokens occur
$qnamesOne or more element or attribute names for which index terms are returned
$startThe optional start string
$functionThe callback function reference
$returnMaxThe maximum number of terms to report

Returns the results from the evaluation of the function reference

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.
$nodesThe set of nodes in which the returned tokens occur
$startThe optional start string
$functionThe callback function reference
$returnMaxThe maximum number of terms to report

Returns the results from the evaluation of the function reference

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.
$textThe text nodes
$widthThe width
$callback-functionThe callback function
$parametersThe parameters passed into the last argument of the callback function

Returns the results

Deprecated: Improved kwic functionality is now provided by a separate XQuery module, see http://exist-db.org/kwic.html. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$textThe text nodes
$widthThe width
$callback-functionThe callback function
$result-callbackThe result callback function
$parametersThe parameters passed into the last argument of the callback function

Returns the results

Deprecated: Improved kwic functionality is now provided by a separate XQuery module, see http://exist-db.org/kwic.html. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

text:make-token($text as xs:string) xs:string*
Split a string into tokens
$textThe string to tokenize

Returns a sequence of tokens

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'.
$sourceThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index

Returns the sequence of all of the matching nodes

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'.
$sourceThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index
$flagWith '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($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'.
$sourceThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index

Returns the sequence of all of the matching nodes

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'.
$sourceThe node set that is to be searched for the keyword set
$regular-expressionThe regular expressions to be matched against the fulltext index
$flagWith '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($source as node()?) xs:integer
Counts the number of fulltext matches within the nodes and subnodes in $source.
$sourceThe node and subnodes to do the fulltext match on

Returns the count

text:text-rank($text as node()?) xs:double
This is just a skeleton for a possible ranking function. Don't use this.
$textThe text to rank

Returns the ranking of the text

http://exist-db.org/xquery/transform
A module for dealing with XSL transformations.

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.
$node-treeThe source-document (node tree)
$stylesheetThe XSL stylesheet
$parametersThe 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.
$node-treeThe source-document (node tree)
$stylesheetThe XSL stylesheet
$parametersThe transformer parameters
$serialization-optionsThe serialization options

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.
$node-treeThe source-document (node tree)
$stylesheetThe XSL stylesheet
$parametersThe 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.
$node-treeThe source-document (node tree)
$stylesheetThe XSL stylesheet
$parametersThe transformer parameters
$serialization-optionsThe serialization options

Returns the transformed result (node tree)

http://exist-db.org/xquery/util
A module for various utility extension functions.

util:base-to-integer($number as item(), $base as xs:integer) xs:integer
Converts the number $number from base $base to xs:integer.
$numberThe number to convert
$baseThe base of $number

Returns the xs:integer representation of $number in base $base

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.
$binary-resourceThe path to the binary resource

Returns the binary document

util:binary-doc-available($binary-resource as xs:string?) xs:boolean
Checks if the binary resource identified by $binary-resource is available.
$binary-resourceThe path to the binary resource

Returns true if the binary document is available

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.
$binary-resourceThe 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.
$binary-resourceThe binary resource
$encodingThe encoding type. i.e. 'UTF-8'

Returns the string containing the encoded binary resource

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.
$function-referenceThe function to ba called
$parametersThe parameters to be passed into the function

Returns the results from the function called

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
$java-classnamesThe list of one or more fully qualified Java class names. An entry of '*' will catch all java exceptions.
$try-code-blocksThe code blocks that will be put inside of a the try part of the try-catch statement.
$catch-code-blocksThe 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() 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($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.
$node-or-path-stringThe document node or a path string.

Returns the name of the collection.

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.
$expressionThe XPath/XQuery expression.

Returns the results of the expression

util:declare-namespace($prefix as xs:string, $namespace-uri as xs:anyURI) empty()
Dynamically declares a namespace/prefix mapping for the current context.
$prefixThe prefix to be assigned to the namespace
$namespace-uriThe namespace URI

util:declare-option($name as xs:string, $option as xs:string) empty()
Dynamically declares a serialization option as with 'declare option'.
$nameThe serialization option name
$optionThe serialization option value

util:deep-copy($item as item()?) item()?
Performs a Deep Clone of the passed in item.
$itemThe item to be cloned

Returns the item clone

util:describe-function($function-name as xs:QName) node()
Describes a built-in function. Returns an element describing the function signature.
$function-nameThe name of the function to get the signature of

Returns the signature of the function

util:disable-profiling() empty()
Disable profiling output within the query.

util:doctype($doctype as xs:string+, ...) node()*
Returns the document nodes of the documents with the given DOCTYPE(s).
$doctypeThe DOCTYPE of the documents to find

Returns the document nodes

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.
$node-or-pathThe node or a string path pointing to a resource in the database.

Returns the ID of the document

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.
$node-or-pathThe node or a string path pointing to a resource in the database.

Returns the name of the document

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.
$verbosityThe verbosity of the profiling

util:eval($expression as item()) node()*
Dynamically evaluates an XPath/XQuery expression.
$expressionThe 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.
$expressionThe 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-flagThe 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($inline-context as item()*, $expression as item()) item()*
Dynamically evaluates an XPath/XQuery expression.
$inline-contextThe inline context
$expressionThe 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($expression as item(), $context as node()?, $cache-flag as xs:boolean) node()*
Dynamically evaluates an XPath/XQuery expression.
$expressionThe 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-flagThe 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.
$expressionThe 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-flagThe flag for whether the compiled query should be cached. The cached query will be globally available within the db instance.
$eval-context-itemthe context item against which the expression will be evaluated

Returns the results of the evaluated XPath/XQuery expression

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.
$nodesThe nodes whose owning documents will have exclusive locks set.
$expressionThe expression(s) that are to be evaluated before the acquired locks are released.

Returns the results of the evaluated expression(s)

util:eXist-version() xs:string
Returns the version of eXist running this query.

Returns the version string

Deprecated: Moved to system module and renamed to system:get-version. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$nodeThe 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.
$nodeThe node(s) to create in-memory copies of.
$serialization-parametersThe serialization parameters

Returns the results

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.
$uriThe namespace URI of the function module

Returns the xqdocs for the function module

util:file-read($url as item()) xs:string?
Read the contents of a file as a string.
$urlThe URL of the file to read

Returns the contents of the file

Deprecated: Moved to the file extension module. See file:read() in the file extension module This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

util:file-read($url as item(), $encoding as xs:string) xs:string?
Read the contents of a file as a string.
$urlThe URL of the file to read
$encodingThe encoding of the file

Returns the contents of the file

Deprecated: Moved to the file extension module. See file:read() in the file extension module This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$nameThe name of the function
$arityThe arity of the function

Returns the reference to the XQuery function

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())
$beginning-nodeThe first node/milestone element
$ending-nodeThe second node/milestone element
$make-fragmentThe flag make a fragment.

Returns the string containing the fragments between the two node/milestone elements.

util:get-module-description($namespace-uri as xs:string) xs:string
Returns a short description of the module identified by the namespace URI.
$namespace-uriThe namespace URI of the module

Returns the description of the active function module identified by the namespace URI

util:get-sequence-type($sequence-type as xs:anyType*) xs:string
Returns the string representation of the type of sequence.
$sequence-typeThe type of sequence

Returns the string representation of the type of sequence

util:hash($message as item(), $algorithm as xs:string) xs:string
Calculates a hashcode from a string based on a specified algorithm.
$messageThe string to generate the hashcode from
$algorithmThe 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.
$messageThe string to generate the hashcode from
$algorithmThe algorithm used to generate the hashcode
$base64flagThe flag that specifies whether to return the result as Base64 encoded

Returns the hashcode

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.
$module-uriThe namespace URI of the module
$prefixThe prefix to be assigned to the namespace
$locationThe location of the module

util:index-key-documents($nodes as node()*, $value as xdt:anyAtomicType) xs:integer?
Return the number of documents for an indexed value.
$nodesThe nodes whose content is indexed
$valueThe 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.
$nodesThe nodes whose content is indexed
$valueThe indexed value to search for
$indexThe index in which the search is made

Returns the number of documents for the indexed value

util:index-key-occurrences($nodes as node()*, $value as xdt:anyAtomicType) xs:integer?
Return the number of occurrences for an indexed value.
$nodesThe nodes whose content is indexed
$valueThe 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.
$nodesThe nodes whose content is indexed
$valueThe indexed value to search for
$indexThe index in which the search is made

Returns the number of occurrences for the indexed value

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.
$node-setThe node set
$start-valueOnly 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-referenceThe 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-returnedThe 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.
$node-setThe node set
$start-valueOnly 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-referenceThe 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-returnedThe maximum number of returned keys
$indexThe index in which the search is made

Returns the results of the eval of the $function-reference

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.
$set-of-nodesThe set of nodes

Returns the range index type

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.
$numberThe number to convert
$baseThe base of $number

Returns the xs:string representation of $number in base $base

util:is-binary-doc($binary-resource as xs:string?) xs:boolean
Checks if the resource identified by $binary-resource is a binary resource.
$binary-resourceThe path to the binary resource

Returns true if the resource is a binary document

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.
$namespace-uriThe namespace URI of the module

Returns true if the namespace URI is registered as an active function module

util:log($priority as xs:string, $message as item()*) empty()
Logs the message to the current logger.
$priorityThe logging priority: 'error', 'warn', 'debug', 'info', 'trace'
$messageThe message to log

util:log-app($priority as xs:string, $logger-name as xs:string, $message as item()*) empty()
Logs the message to the named logger
$priorityThe logging priority: 'error', 'warn', 'debug', 'info', 'trace'
$logger-nameThe name of the logger, eg: my.app.log
$messageThe message to log

util:log-system-err($message as item()*) empty()
Logs the message to System.err.
$messageThe message to log

util:log-system-out($message as item()*) empty()
Logs the message to System.out.
$messageThe message to log

util:md5($arg as item()) xs:string
Generates an MD5 key from a string.
$argThe input string

Returns the MD5 key

Deprecated: Use the hash($a, "MD5") function instead. SHA-1 is supported as more secure message digest algorithm. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

util:md5($arg as item(), $base64encoded as xs:boolean) xs:string
Generates an MD5 key from a string. $b specifies whether to return result Base64 encoded
$argThe input string
$base64encodedThe flag to determine if the result is Base64 encoded

Returns the MD5 key

Deprecated: Use the hash($a, "MD5") function instead. SHA-1 is supported as more secure message digest algorithm. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$documentThe document whose node is to be retrieved by its id
$node-idThe internal node id

Returns the node

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.
$nodeThe node to get the internal node-id from

Returns the internal node-id

util:node-xpath($node as node()) xs:string?
Returns the XPath for a Node.
$nodeThe node to retrieve the XPath to

Returns the XPath expression of the node

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.
$to-be-parsedThe string to be parsed

Returns the XML fragment parsed from the string

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.
$to-be-parsedThe string to be parsed

Returns the XML fragment parsed from the string

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.
$qnameThe QName
$comparison-valueThe comparison value

Returns the result

util:random($max as xs:integer) xs:integer
Returns a random number between 0 and $max
$maxThe maximum value for the random number.

Returns a random number between 0 and $max

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: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.
$namespace-uriThe namespace URI of the function module

Returns the sequence of function names

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-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($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.

Deprecated: Use the file:serialize() function in the file extension module instead! This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$node-setThe node set to serialize
$parametersThe serialization parameters

Returns the string containing the serialized node set.

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.
$nodesThe nodes that the shared lock will be placed on their owning documents.
$expressionThe expression to be evaluated before the acquired locks are released.

Returns the results of the evaluation of the expression(s)

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.
$encoded-stringThe 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.
$encoded-stringThe string containing the encoded binary resource
$encodingthe encoding type. i.e. 'UTF-8'

Returns the binary resource

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() 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($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.
$property-nameThe name of the system property to retrieve the value of.

Returns the value of the named system property

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($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()
$escaped-stringThe escaped string to be un-escaped
$encodingThe encoding scheme to use in the un-escaping of the string

Returns the un-escaped string

util:uuid($name as item()) xs:string
Generate a version 3 universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6
$nameThe input value for UUID calculation.

Returns a generated UUID string

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

http://exist-db.org/xquery/validation
A module for XML validation and grammars functions.

validation:clear-grammar-cache() xs:integer
Remove all cached grammers.

Returns the number of deleted grammars.

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'.
$instanceThe document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object.
$cache-grammarsSet 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'.
$instanceThe document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object.
$cache-grammarsSet the flag to true() to enable grammar caching.
$catalogsThe 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($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).
$instanceThe document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object.
$enable-grammar-cacheSet the flag to true() to enable grammar caching.
$catalogsThe catalogs referenced as xs:anyURI's.

Returns the parsed document.

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.
$instanceThe document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object.
$enable-grammar-cacheSet 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.
$instanceThe document referenced as xs:anyURI, a node (element or result of fn:doc()) or as a Java file object.
$enable-grammar-cacheSet the flag to true() to enable grammar caching.
$catalogsThe catalogs referenced as xs:anyURI's.

Returns a validation report.

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.
$instanceThe document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object.
$grammarsOne 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($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.
$instanceThe document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object.
$grammarsOne 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($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'.
$instanceThe document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object.
$grammarThe 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($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.
$instanceThe document referenced as xs:anyURI, a node (element or returned by fn:doc()) or as a Java file object.
$grammarThe 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($grammar as xs:anyURI*) xs:string*
Pre parse grammars and add to grammar cache. Only XML schemas (.xsd) are supported.
$grammarReference to grammar.

Returns sequence of namespaces of preparsed grammars.

validation:show-grammar-cache() node()
Show all cached grammars.

Returns an XML document containing details on all cached grammars.

validation:validate($instance as item()) xs:boolean
Validate xml. The grammar files (DTD, XML Schema) are resolved using the global catalog file(s).
$instanceThe 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.

Deprecated: Use the validation:parse(), validation:jaxv() or valation:jing() functions. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

validation:validate($instance as item(), $grammar as xs:anyURI) node()
Validate document by using a specific grammar.
$instanceThe document referenced as xs:anyURI or a node (element or returned by fn:doc())
$grammarThe 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.

Deprecated: Use the validation:parse(), validation:jaxv() or valation:jing() functions. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$instanceThe document referenced as xs:anyURI or a node (element or returned by fn:doc())

Returns a validation report.

Deprecated: Use the validation:parse-report(), validation:jaxv-report() or valation:jing-report() functions. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

validation:validate-report($instance as item(), $grammar as xs:anyURI) node()
Validate document by using a specific grammar. An xml report is returned.
$instanceThe document referenced as xs:anyURI or a node (element or returned by fn:doc())
$grammarThe 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.

Deprecated: Use the validation:parse-report(), validation:jaxv-report() or valation:jing-report() functions. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

http://exist-db.org/xquery/xmldb
A module for database manipulation functions.

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.
$collection-uriThe collection URI
$user-idThe user-id
$passwordThe password

Returns true() on successful authentication, false() otherwise

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.
$user-idThe user-id
$passwordThe password
$groupsThe groups the user is member of
$home-collectionThe user's home 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.
$collectionThe collection path
$modeThe mode as xs:integer

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.
$collectionThe collection
$resourceThe resource
$modeThe mode as xs:integer

xmldb:collection-available($collection-path as xs:string) xs:boolean
Returns true() if the collection $collection exists and is available, otherwise false().
$collection-pathThe collection path

Returns true() if the collection exists and is available, false() otherwise

xmldb:collection-exists($collection-path as xs:string, ...) xs:boolean
Returns true() if the collection $collection exists and is available, otherwise false().
$collection-pathThe collection path

Returns true() if the collection exists and is available, false() otherwise

Deprecated: Use xmldb:collection-available() instead. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$source-collection-uriThe source collection URI
$target-collection-uriThe 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.
$source-collection-uriThe source collection URI
$target-collection-urithe target collection URI
$resourcethe resource to copy

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.
$target-collection-uriThe target collection URI
$new-collectionThe name of the new collection to create

Returns the path to the new collection if successfully created, otherwise the empty sequence

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.
$user-idThe user-id
$passwordThe password
$groupsThe group memberships
$home-collection-uriThe home collection URI

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.
$collection-uriThe 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.
$collection-uriThe collection URI
$resourceThe resource

Returns the creation date

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.
$stringThe input string

Returns the decoded string

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.
$uriThe URI

Returns the decoded $uri as xs:string

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.
$nodesThe 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.
$nodesThe sequence of nodes from the documents to defragment
$integerThe minimum number of fragmented pages required before defragmenting

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.
$user-idThe user-id to delete

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.
$document-urisThe document URIs

Returns the documents

Deprecated: See the standard fn:doc() function This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

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.
$collection-uriThe collection URI
$resourceThe resource

Returns the user id of the lock owner, otherwise if not locked the empty sequence

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.
$stringThe input string

Returns the URL encoded string

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
$stringThe input string

Returns the XmldbURI encoded from $string

xmldb:exists-user($user-id as xs:string) xs:boolean
Returns true if the user $user-id exists.
$user-idThe user-id

Returns true() if the user exists, false() otherwise

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.
$collection-uriThe collection URI

Returns the sequence of child collection names

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.
$collection-uriThe collection URI

Returns the sequence of resource names

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($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.
$collection-uriThe 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.
$collection-uriThe collection URI
$resourceThe resource

Returns the owner group

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.
$resource-uriThe resource URI

Returns the mime-type if available, otherwise the empty sequence

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.
$collection-uriThe 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.
$collection-uriThe collection URI
$resourceThe resource

Returns the user-id

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.
$collection-uriThe 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.
$collection-uriThe collection-uri
$resourceThe resource

Returns the resource permissions

xmldb:get-user-groups($user-id as xs:string) xs:string+
Returns the sequence of groups the user $user-id is a member of.
$user-idThe user-id

Returns the group memberships

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.
$user-idThe user-id

Returns the home collection URI of user $user-id if one is assigned, otherwise the empty sequence

xmldb:is-admin-user($user-id as xs:string) xs:boolean?
Returns true() if user $user-id has DBA role, false() otherwise.
$user-idThe user-id

Returns true() if user has DBA role, false() otherwise

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.
$collection-uriThe collection URI
$resourceThe resource

Returns the last modification date

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.
$collection-uriThe collection URI
$user-idThe user-id
$passwordThe 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.
$collection-uriThe collection URI
$user-idThe user-id
$passwordThe password
$create-sessionwhether to create the session or not on successful authentication, default false()

Returns true() on successful authentication and owner elevation, false() otherwise

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.
$source-collection-uriThe source collection URI
$target-collection-uriThe 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.
$source-collection-uriThe source collection URI
$target-collection-uriThe target collection URI
$resourceThe resource

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.
$permissionsThe permissions in xs:integer format

Returns the permissions as string 'rwu' for, user, group and other

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.
$driverThe DB driver
$create-dbThe flag to create the db if it does not exist

Returns true() if successfully registered, false() otherwise

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.
$collection-pathThe collection path

Returns true() if successfully reindexed, false() otherwise

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.
$collection-uriThe 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.
$collection-uriThe collection URI
$resourceThe resource

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.
$collection-uriThe collection URI
$resourceThe resource
$new-resource-nameThe new resource name

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.
$source-collection-uriThe source collection URI
$new-collection-nameThe new collection name

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.
$collection-uriThe collection URI
$user-idThe user-id
$group-idThe group-id
$permissionsThe 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.
$collection-uriThe collection URI
$resourceThe resource
$user-idThe user-id
$group-idThe group-id
$permissionsThe permissions

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.
$collection-uriThe collection URI
$resourceThe resource

Returns the size of the pages, occupied by the resource, in bytes

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.
$collection-uriThe collection URI
$resource-nameThe resource name
$contentsThe 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.
$collection-uriThe collection URI
$resource-nameThe resource name
$contentsThe contents
$mime-typeThe mime type

Returns the path to new resource if sucessfully stored, otherwise the emtpty sequence

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).
$collection-uriThe collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directoryThe directory in the file system from where the files are read.
$patternThe 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).
$collection-uriThe collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directoryThe directory in the file system from where the files are read.
$patternThe 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-typeIf 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).
$collection-uriThe collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directoryThe directory in the file system from where the files are read.
$patternThe 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-typeIf the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource.
$preserve-structureIf 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($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.
$collection-uriThe collection URI
$modificationsThe XUpdate modifications to be processed

Returns the number of modifications, as xs:integer, caused by the XUpdate

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.
$collection-urisThe collection URIs

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

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

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

Returns the absolute value of the argument

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

Returns the adjusted date

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

Returns the adjusted date

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

Returns the adjusted date-time

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

Returns the adjusted date-time

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

Returns the adjusted time

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

Returns the adjusted time

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

Returns the average of the values in the input sequence

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

Returns the base URI from $uri

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

Returns the base URI from the context item

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

Returns the boolean value, ebv, of the items

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

Returns the non-fractional number not less than $number

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

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

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

Returns the string constructed from the codepoints if valid

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

Returns the document nodes contained in or under the given collections

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

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

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

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

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

Returns the concatenated values

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

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

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

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

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

Returns the number of items in the argument sequence

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

Returns the date current within the query execution time span

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

Returns the date-time current within query execution time span

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

Returns the time current within query execution time span

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

Returns the atomic values of the items in $items

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

Returns the combined date and time as xs:dateTime

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

Returns the day component from $date

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

Returns the day component from $date-time

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

Returns the days component of $duration

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

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

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

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

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

Returns the default collation from the context

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

Returns the distinct values sequence

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

Returns the distinct values sequence

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

Returns the document node of $document-uri

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

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

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

Returns the document nodes matching the DOCTYPE names

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

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

Returns the documents

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

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

Returns the document URI of $document-node

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

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

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

Returns the URI part with reserved characters percent encoded

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

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

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

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

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

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

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

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

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

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

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

Returns the identified characters in $uri encoded with escape sequences

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

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

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

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

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

Returns false

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

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

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

Returns the hours component from $date-time

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

Returns the hours component of $duration

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

Returns the hours component from $time

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

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

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

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

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

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

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

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

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

Returns the implicit timezone daytime-duration from the dynamic context

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

Returns the prefixes

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

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

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

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

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

Returns the new sequence

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

Returns the URI

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

Returns the item

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

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

Returns true if the language code matches, false otherwise

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

Returns true if the language code matches, false otherwise

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

Returns the context size from the dynamic context

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

Returns the local name

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

Returns the local name

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

Returns the local name

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

Returns the resulting lower-case text

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

Returns the sequence of all of the matching nodes

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

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

Returns the sequence of all of the matching nodes

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

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

Returns true if the pattern is a match, false otherwise

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

Returns true if the pattern is a match, false otherwise

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

Returns the max value

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

Returns the max value

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

Returns the minimum value

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

Returns the minimum value

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

Returns the minutes component from $date-time

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

Returns the minutes component of $duration

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

Returns the minutes component from $time

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

Returns the month component from $date

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

Returns the month component from $date-time

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

Returns the months component of $duration

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

Returns the name

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

Returns the name

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

Returns the namespace URI

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

Returns the namespace URI

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

Returns the namespace URI

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

Returns the namespace URI

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

Returns true if the argument node is "nilled"

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

Returns the expanded QName

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

Returns the normalized text

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

Returns the normalized text

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

Returns the normalized text

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

Returns the normalized text

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

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

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

Returns the numerical value

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

Returns the numerical value

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

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

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

Returns the context position

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

Returns the prefix

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

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

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

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

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

Returns the altered string

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

Returns the altered string

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

Returns the QName of $element with lexical form $qname

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

Returns the absolute URI

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

Returns the absolute URI

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

Returns the reverse order sequence

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

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

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

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

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

Returns the rounded value

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

Returns the rounded value

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

Returns the rounded value

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

Returns the seconds component from $date-time

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

Returns the seconds component of $duration

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

Returns the seconds component from $time

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

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

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

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

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

Returns the base URI from the static context

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

Returns the value of $arg as an xs:string

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

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

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

Returns the joined string

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

Returns the length in characters

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

Returns the length in characters

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

Returns the duplicated string

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

Returns the sequence of code points

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

Returns the subsequence

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

Returns the subsequence

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

Returns the substring

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

Returns the substring

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

Returns the substring after $search

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

Returns the substring after $search

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

Returns the substring before $search

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

Returns the substring before $search

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

Returns the sum of all numbers in $arg

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

Returns the sum of all numbers in $arg

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

Returns the timezone component from $date

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

Returns the timezone component from $date-time

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

Returns the timezone component from $time

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

Returns the token sequence

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

Returns the token sequence

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

Returns the labelled $value in the log

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

Returns the translated string

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

Returns true

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

Returns the input sequence in an arbitrary implementation dependent permutation

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

Returns the resulting upper-case text

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

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

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

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

Returns the year component from $date

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

Returns the year component from $date-time

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

Returns the years component of $duration

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

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