A module for various utility extension functions.
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-resource? | The path to the binary resource |
Checks if the binary resource identified by $binary-resource is available.
$binary-resource? | The path to the binary resource |
Gets the digest of the content of the resource identified by $binary-resource.
$binary-resource? | The path to the binary resource |
$algorithm | The name of the algorithm to use for calculating the digest. Supports: MD2, MD4, MD5, SHA-1, SHA-256, SHA-512, RIPEMD-160, RIPEMD-256, BLAKE2B-160, BLAKE2B-256, BLAKE2B-512 |
Dynamically evaluates an XPath/XQuery expression.
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
Dynamically evaluates an XPath/XQuery expression.
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$cache-flag | The flag for whether the compiled query should be cached. The cached querywill be globally available within the db instance. |
Dynamically evaluates an XPath/XQuery expression.
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$cache-flag | The flag for whether the compiled query should be cached. The cached querywill be globally available within the db instance. |
$external-variable* | External variables to be bound for the query that is being evaluated. Should be alternating variable QName and value. |
Dynamically evaluates an XPath/XQuery expression and serializes the results
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$default-serialization-params? | The default parameters for serialization, these maybe overridden by any settings within the XQuery Prolog of the $expression. |
Dynamically evaluates an XPath/XQuery expression and serializes the results
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$default-serialization-params? | The default parameters for serialization, these maybe overridden by any settings within the XQuery Prolog of the $expression. |
$starting-loc | the starting location within the results to return the values from |
Dynamically evaluates an XPath/XQuery expression and serializes the results
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$default-serialization-params? | The default parameters for serialization, these maybe overridden by any settings within the XQuery Prolog of the $expression. |
$starting-loc | the starting location within the results to return the values from |
$length | the number of items from $starting-loc to return the values of |
Dynamically evaluates an XPath/XQuery expression.
$inline-context? | The inline context |
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
Dynamically evaluates an XPath/XQuery expression.
$inline-context? | The inline context |
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$cache-flag | The flag for whether the compiled query should be cached. The cached querywill be globally available within the db instance. |
Dynamically evaluates an XPath/XQuery expression.
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$context? | The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"/> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. |
$cache-flag | The flag for whether the compiled query should be cached. The cached querywill be globally available within the db instance. |
Dynamically evaluates an XPath/XQuery expression.
$expression | The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. |
$context? | The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"/> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. |
$cache-flag | The flag for whether the compiled query should be cached. The cached querywill be globally available within the db instance. |
$eval-context-item? | the context item against which the expression will be evaluated |
Checks if the resource identified by $binary-resource is a binary resource.
$binary-resource? | The path to the binary resource |
Can be used to query existing qname indexes defined on a set of nodes.
$qname | The QName |
$comparison-value | The comparison value |
Can be used to query existing qname indexes defined on a set of nodes.
$qname | The QName |
$comparison-value | The comparison value |
$element-or-attribute | true() to lookup an element, false to lookup an attribute |
Returns the absolute internal id of a resource as a 65 bit number. The first 32 bits are the collection id, the next 32 bits are the document id, the last bit is the document type. 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-path | The node or a string path pointing to a resource in the database. |
Converts the number $number from base $base to xs:integer.
$number | The number to convert |
$base | The base of $number |
Decode the given Base64 encoded string back to clear text
$string? | The Base64 string to be decoded |
Encodes the given string as Base64
$string? | The string to be Base64 encoded |
Encodes the given string as Base64
$string? | The string to be Base64 encoded |
$trim | Trim trailing newlines? |
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-resource? | The binary resource |
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-resource? | The binary resource |
$encoding | The encoding type. i.e. 'UTF-8' |
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-reference | The function to ba called |
$parameters* | The parameters to be passed into the function |
Returns a sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI.
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-string? | The document node or a path string. |
Compiles the XQuery expression given in parameter $expression. Returns an empty string if no errors were found, a description of the error otherwise.
$expression | The XPath/XQuery expression. |
Compiles the XQuery expression given in parameter $expression. Returns an empty string if no errors were found, a description of the error otherwise.
$expression | The XPath/XQuery expression. |
$module-load-path | The module load path. Imports will be resolved relative to this. Use xmldb:exist:///db if your modules are stored in db. |
Compiles the XQuery expression given in parameter $expression. Returns an XML fragment which describes any errors found. If the query could be compiled successfully, a fragment <info result="pass"/> is returned. Otherwise, an error description is returned as follows: <info result="fail"><error code="errcode" line="line" column="column">error description</error></info>.
$expression | The XPath/XQuery expression. |
$module-load-path? | The module load path. Imports will be resolved relative to this. Use xmldb:exist:///db if your modules are stored in db. |
Dynamically declares a namespace/prefix mapping for the current context.
$prefix | The prefix to be assigned to the namespace |
$namespace-uri | The namespace URI |
Dynamically declares a serialization option as with 'declare option'.
$name | The serialization option name |
$option | The serialization option value |
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-uri | The namespace URI of the function module |
Creates a new, entirely in-memory copy of the passed in item.
$item? | The item to be copied |
Describes a built-in function. Returns an element describing the function signature.
$function-name | The name of the function to get the signature of |
Disable profiling output within the query.
Returns the document nodes of the documents with the given DOCTYPE(s).
$doctype+ | The DOCTYPE of the documents to find |
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-path | The node or a string path pointing to a resource in the database. |
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-path | The node or a string path pointing to a resource in the database. |
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.
$verbosity | The verbosity of the profiling |
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.
$nodes* | The nodes whose owning documents will have exclusive locks set. |
$expression* | The expression(s) that are to be evaluated before the acquired locks are released. |
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 <exist:match> and XIncludes will be expanded.
$node* | The node(s) to create in-memory copies of. |
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 <exist:match> and XIncludes will be expanded. Serialization parameters can be set in the second argument, which accepts the same parameters as the exist:serialize option.
$node* | The node(s) to create in-memory copies of. |
$serialization-parameters | The serialization parameters |
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.
$name | The name of the function |
$arity | The arity of the function |
Returns an xml fragment or a sequence of nodes between two elements (normally milestone elements). This function works only on documents which are stored in eXist DB.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. The fourth argument, display-root-namespace, is a boolean value for displaying the root node namespace. If it is set to true() the attribute "xmlns" in the root node of the result sequence is determined explicitely from the $beginning-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(), true())
$beginning-node | The first node/milestone element |
$ending-node? | The second node/milestone element |
$make-fragment? | The flag make a fragment. |
$display-root-namespace? | Display the namespace of the root node of the fragment. |
Returns a short description of the module identified by the namespace URI.
$namespace-uri | The namespace URI of the module |
Returns an XML fragment providing additional information about the module identified by the namespace URI.
Returns an XML fragment providing additional information about the module identified by the namespace URI.
$namespace-uri | The namespace URI of the module |
Gets the value of a serialization option as set with 'declare option'.
$name | The serialization option name |
Returns the resource indicated by its absolute internal id. The first 32 bits are the collection id, the next 32 bits are the document id, the last bit is the document type. If the resource does not exist, the empty sequence is returned.
$absolute-id | The absolute id of a resource in the database. |
Returns the string representation of the type of sequence.
$sequence-type* | The type of sequence |
Calculates a hashcode from a string based on a specified algorithm.
$message | The string to generate the hashcode from |
$algorithm | The algorithm used to generate the hashcode |
Calculates a hashcode from a string based on a specified algorithm.
$message | The string to generate the hashcode from |
$algorithm | The algorithm used to generate the hashcode |
$base64flag | The flag that specifies whether to return the result as Base64 encoded |
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-uri | The namespace URI of the module |
$prefix | The prefix to be assigned to the namespace |
$location | The location of the module |
Return the number of documents for an indexed value.
$nodes* | The nodes whose content is indexed |
$value | The indexed value to search for |
Return the number of documents for an indexed value.
$nodes* | The nodes whose content is indexed |
$value | The indexed value to search for |
$index | The index in which the search is made |
Return the number of occurrences for an indexed value.
$nodes* | The nodes whose content is indexed |
$value | The indexed value to search for |
Return the number of occurrences for an indexed value.
$nodes* | The nodes whose content is indexed |
$value | The indexed value to search for |
$index | The index in which the search is made |
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-set* | The node set |
$start-value? | Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. |
$function-reference | The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. |
$max-number-returned? | The maximum number of returned keys |
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.
Read more$node-set* | The node set |
$start-value? | Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. |
$function-reference | The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. |
$max-number-returned? | The maximum number of returned keys |
$index | The index in which the search is made |
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.
$qname* | The node set |
$start-value? | Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. |
$function-reference | The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. |
$max-number-returned? | The maximum number of returned keys |
$index | The index in which the search is made |
Returns the range index type for a set of nodes or an empty sequence if no index is defined.
$set-of-nodes* | The set of nodes |
Returns an XML fragment describing the function referenced by the passed function item.
$function | The function item to inspect |
Converts an int e.g. 511 to an octal number e.g. 0777.
$int | The int to convert to an octal string. |
Converts the xs:integer $number (unsigned) into base $base as xs:string. Bases 2, 8, and 16 are supported.
$number | The number to convert |
$base | The base of $number |
Returns a Boolean value if the module statically mapped to a source location in the configuration file.
$namespace-uri | The namespace URI of the module |
Returns a Boolean value if the module identified by the namespace URI is registered.
$namespace-uri | The namespace URI of the module |
Retrieves the line number of the expression
Returns a sequence of function items for each function in the current module.
Returns a sequence of function items for each function in the specified module.
$namespace-uri | The namespace URI of the function module |
Logs the message to the current logger.
$priority | The logging priority: 'error', 'warn', 'debug', 'info', 'trace' |
$message* | The message to log |
Logs the message to the named logger
$priority | The logging priority: 'error', 'warn', 'debug', 'info', 'trace' |
$logger-name | The name of the logger, eg: my.app.log |
$message* | The message to log |
Logs the message to System.err.
$message* | The message to log |
Logs the message to System.out.
$message* | The message to log |
Map the module to a source location. This function is only available to the DBA role.
$namespace-uri | The namespace URI of the module |
$location-uri | The location URI of the module |
Returns a sequence containing the namespace URIs of all XQuery modules which are statically mapped to a source location in the configuration file. This does not include any built in modules.
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.
$document | The document whose node is to be retrieved by its id |
$node-id | The internal node id |
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.
$node | The node to get the internal node-id from |
Returns the XPath for a Node.
$node | The node to retrieve the XPath to |
Converts an octal string e.g. '0777' to an int e.g. 511.
$octal | The octal string to convert to an int. |
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-parsed? | The string to be parsed |
Returns a random number between 0.0 and 1.0
Returns a random number between 0 (inclusive) and $max (exclusive), that is, a number greater than or equal to 0 but less than $max
$max | A number to be used as the exclusive maximum value for the random number; the return value will be less than this number. |
Returns a random number between 0 and the maximum xs:unsignedLong
Returns a sequence containing the QNames of all functions currently known to the system, including functions in imported and built-in modules.
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-uri | The namespace URI of the function module |
Returns a sequence containing the namespace URIs of all modules currently known to the system, including built in and imported modules.
Returns the contents of a string as an base64binary value. The string data is transformed into a binary using the encoding specified in the optional second argument or the default of UTF-8.
$encoded-string? | The string containing the encoded binary resource |
Returns the contents of a string as a base64binary value. The string data is transformed into a binary using the encoding specified in the optional second argument or the default of UTF-8.
$encoded-string? | The string containing the encoded binary resource |
$encoding | the encoding type. i.e. 'UTF-8' |
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: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 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-name | The name of the system property to retrieve the value of. |
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 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-string | The escaped string to be un-escaped |
$encoding | The encoding scheme to use in the un-escaping of the string |
Remove relation between module namespace and source location. This function is only available to the DBA role.
$namespace-uri | The namespace URI of the module |
Generate a version 4 (random) universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6
Generate a version 3 universally unique identifier (UUID) string, e.g. 2b92ddb6-8e4e-3891-b519-afa1609ced73
$name | The input value for UUID calculation. |
Wait for the specified number of milliseconds
$interval | Number of milliseconds to wait. |