XQuery Function Documentation
http://exist-db.org/xquery/util
java:org.exist.xquery.functions.util.UtilModule
A module for various utility extension functions.
util:absolute-resource-id
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.
- Parameters:
-
$node-or-path The node or a string path pointing to a resource in the database. - Returns:
- xs:integer? : the absolute ID of the resource
util:base-to-integer
Converts the number $number from base $base to xs:integer.
- Parameters:
-
$number The number to convert $base The base of $number - Returns:
- xs:integer : the xs:integer representation of $number in base $base
util:base64-decode
Decode the given Base64 encoded string back to clear text
- Parameters:
-
$string? The Base64 string to be decoded - Returns:
- xs:string? : the decoded output
util:base64-encode
Encodes the given string as Base64
- Parameters:
-
$string? The string to be Base64 encoded - Returns:
- xs:string? : the Base64 encoded output, with trailing newlines trimmed
util:base64-encode
Encodes the given string as Base64
- Parameters:
-
$string? The string to be Base64 encoded $trim Trim trailing newlines? - Returns:
- xs:string? : the Base64 encoded output
util:binary-doc
Retrieves the binary resource and returns its contents as a value of type xs:base64Binary. An empty sequence is returned if the resource could not be found or $binary-resource was empty.
- Parameters:
-
$binary-resource? The path to the binary resource - Returns:
- xs:base64Binary? : the binary document
util:binary-doc-available
Checks if the binary resource identified by $binary-resource is available.
- Parameters:
-
$binary-resource? The path to the binary resource - Returns:
- xs:boolean : true if the binary document is available
util:binary-to-string
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8.
- Parameters:
-
$binary-resource? The binary resource - Returns:
- xs:string? : the string containing the encoded binary resource
util:binary-to-string
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or the default of UTF-8.
- Parameters:
-
$binary-resource? The binary resource $encoding The encoding type. i.e. 'UTF-8' - Returns:
- xs:string? : the string containing the encoded binary resource
util:call
Invokes a first-class function reference created by util:function. The function to be called is passed as the first argument. All remaining arguments are forwarded to the called function.
- Parameters:
-
$function-reference The function to ba called $parameters* The parameters to be passed into the function - Returns:
- item()* : the results from the function called
util:catch
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. Inside the catch code block, the variable $util:exception will be bound to the java class name of the exception, and $util:exception-message will be bound to the message produced by the exception.
- Parameters:
-
$java-classnames+ The list of one or more fully qualified Java class names. An entry of '*' will catch all java exceptions. $try-code-blocks* The code blocks that will be put inside of a the try part of the try-catch statement. $catch-code-blocks* The code blocks that will be will called if the catch matches one of the $java-classnames - Returns:
- item()* : the results from the try-catch
- Deprecated:
- Use the XQuery 3.0 try/catch expression instead. This function could be removed in the next major release version.
util:collations
Returns a sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI.
- Returns:
- xs:string* : the sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI.
util:collection-name
Returns the name of the collection from a passed node or path string. If the argument is a node, the function returns the name of the collection to which the node's document belongs. If the argument is a string, it is interpreted as path to a resource and the function returns the computed parent collection path for this resource.
- Parameters:
-
$node-or-path-string? The document node or a path string. - Returns:
- xs:string? : the name of the collection.
util:compile
Compiles the XQuery expression given in parameter $expression. Returns an empty string if no errors were found, a description of the error otherwise.
- Parameters:
-
$expression The XPath/XQuery expression. - Returns:
- xs:string : the results of the expression
util:compile
Compiles the XQuery expression given in parameter $expression. Returns an empty string if no errors were found, a description of the error otherwise.
- Parameters:
-
$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. - Returns:
- xs:string : the results of the expression
util:compile-query
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>.
- Parameters:
-
$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. - Returns:
- element() : the results of the expression
util:declare-namespace
Dynamically declares a namespace/prefix mapping for the current context.
- Parameters:
-
$prefix The prefix to be assigned to the namespace $namespace-uri The namespace URI - Returns:
- item()
util:declare-option
Dynamically declares a serialization option as with 'declare option'.
- Parameters:
-
$name The serialization option name $option The serialization option value - Returns:
- item()
util:declared-variables
Returns a sequence containing the QNames of all functions declared in the module identified by the specified namespace URI. An error is raised if no module is found for the specified URI.
- Parameters:
-
$namespace-uri The namespace URI of the function module - Returns:
- xs:string+ : the sequence of function names
util:deep-copy
Performs a Deep Clone of the passed in item.
- Parameters:
-
$item? The item to be cloned - Returns:
- item()? : the item clone
util:describe-function
Describes a built-in function. Returns an element describing the function signature.
- Parameters:
-
$function-name The name of the function to get the signature of - Returns:
- node() : the signature of the function
- Deprecated:
- Moved to the module: http://exist-db.org/xquery/inspection, you should now use 'inspect:inspect-function' instead! This function could be removed in the next major release version.
util:disable-profiling
Disable profiling output within the query.
- Returns:
- item()
util:doctype
Returns the document nodes of the documents with the given DOCTYPE(s).
- Parameters:
-
$doctype+ The DOCTYPE of the documents to find - Returns:
- node()* : the document nodes
util:document-id
Returns the internal integer id of a document. The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned.
- Parameters:
-
$node-or-path The node or a string path pointing to a resource in the database. - Returns:
- xs:int? : the ID of the document
util:document-name
Returns the name of a document (excluding the collection path). The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned.
- Parameters:
-
$node-or-path The node or a string path pointing to a resource in the database. - Returns:
- xs:string? : the name of the document
util:enable-profiling
Enable profiling output within the query. The profiling starts with this function call and will end with a call to 'disable-profiling'. Argument $verbosity specifies the verbosity. All other profiling options can be configured via the 'declare option exist:profiling ...' in the query prolog.
- Parameters:
-
$verbosity The verbosity of the profiling - Returns:
- item()
util:eval
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:eval
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $cache-flag The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:eval
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $cache-flag The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. $external-variable* External variables to be bound for the query that is being evaluated. Should be alternating variable QName and value. - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:eval-async
Dynamically evaluates an XPath/XQuery expression asynchronously. The ID of the executing thread is returned.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:eval-inline
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$inline-context* The inline context $expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. - Returns:
- item()* : the results of the evaluated XPath/XQuery expression
util:eval-inline
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$inline-context* The inline context $expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $cache-flag The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. - Returns:
- item()* : the results of the evaluated XPath/XQuery expression
util:eval-with-context
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $context? The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. $cache-flag The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:eval-with-context
Dynamically evaluates an XPath/XQuery expression.
- Parameters:
-
$expression The expression to be evaluated. If it is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. $context? The query inherits the context described by the XML fragment in this parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <default-context>explicitly provide default context here</default-context> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. $cache-flag The flag for whether the compiled query should be cached. The cached query will be globally available within the db instance. $eval-context-item? the context item against which the expression will be evaluated - Returns:
- node()* : the results of the evaluated XPath/XQuery expression
util:exclusive-lock
Puts an exclusive lock on the owner documents of all nodes in the first argument $nodes. Then evaluates the expressions in the second argument $expression and releases the acquired locks after their completion.
- Parameters:
-
$nodes* The nodes whose owning documents will have exclusive locks set. $expression* The expression(s) that are to be evaluated before the acquired locks are released. - Returns:
- item()* : the results of the evaluated expression(s)
util:expand
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.
- Parameters:
-
$node* The node(s) to create in-memory copies of. - Returns:
- node()* : the results
util:expand
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.
- Parameters:
-
$node* The node(s) to create in-memory copies of. $serialization-parameters The serialization parameters - Returns:
- node()* : the results
util:function
Creates a reference to an XQuery function which can later be called from util:call. This allows for higher-order functions to be implemented in XQuery. A higher-order function is a function that takes another function as argument. The first argument represents the name of the function, which should bea valid QName. The second argument is the arity (number of parameters) of the function. If no function can be found that matches the name and arity, an error is thrown. Please note: the arguments to this function have to be literals or need to be resolvable at compile time at least.
- Parameters:
-
$name The name of the function $arity The arity of the function - Returns:
- function : the reference to the XQuery function
util:get-fragment-between
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())
- Parameters:
-
$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:
- xs:string : the string containing the fragment between the two node/milestone elements.
util:get-module-description
Returns a short description of the module identified by the namespace URI.
- Parameters:
-
$namespace-uri The namespace URI of the module - Returns:
- xs:string : the description of the active function module identified by the namespace URI
- Deprecated:
- Moved to the module: http://exist-db.org/xquery/inspection, you should now use 'inspect:inspect-module-uri' instead! This function could be removed in the next major release version.
util:get-module-info
Returns an XML fragment providing additional information about the module identified by the namespace URI.
- Returns:
- element() : the description of the active function module identified by the namespace URI
util:get-module-info
Returns an XML fragment providing additional information about the module identified by the namespace URI.
- Parameters:
-
$namespace-uri The namespace URI of the module - Returns:
- element() : the description of the active function module identified by the namespace URI
- Deprecated:
- Moved to the module: http://exist-db.org/xquery/inspection, you should now use 'inspect:inspect-module-uri' instead! This function could be removed in the next major release version.
util:get-option
Gets the value of a serialization option as set with 'declare option'.
- Parameters:
-
$name The serialization option name - Returns:
- xs:string?
util:get-resource-by-absolute-id
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.
- Parameters:
-
$absolute-id The absolute id of a resource in the database. - Returns:
- item()? : The resource from the database. A document() if its an XML resource, or an xs:base64binary otherwise
util:get-sequence-type
Returns the string representation of the type of sequence.
- Parameters:
-
$sequence-type* The type of sequence - Returns:
- xs:string : the string representation of the type of sequence
util:hash
Calculates a hashcode from a string based on a specified algorithm.
- Parameters:
-
$message The string to generate the hashcode from $algorithm The algorithm used to generate the hashcode - Returns:
- xs:string : the hashcode
util:hash
Calculates a hashcode from a string based on a specified algorithm.
- Parameters:
-
$message The string to generate the hashcode from $algorithm The algorithm used to generate the hashcode $base64flag The flag that specifies whether to return the result as Base64 encoded - Returns:
- xs:string : the hashcode
util:import-module
Dynamically imports an XQuery module into the current context. The parameters have the same meaning as in an 'import module ...' expression in the query prolog.
- Parameters:
-
$module-uri The namespace URI of the module $prefix The prefix to be assigned to the namespace $location The location of the module - Returns:
- item()
util:index-key-documents
Return the number of documents for an indexed value.
- Parameters:
-
$nodes* The nodes whose content is indexed $value The indexed value to search for - Returns:
- xs:integer? : the number of documents for the indexed value
util:index-key-documents
Return the number of documents for an indexed value.
- Parameters:
-
$nodes* The nodes whose content is indexed $value The indexed value to search for $index The index in which the search is made - Returns:
- xs:integer? : the number of documents for the indexed value
util:index-key-occurrences
Return the number of occurrences for an indexed value.
- Parameters:
-
$nodes* The nodes whose content is indexed $value The indexed value to search for - Returns:
- xs:integer? : the number of occurrences for the indexed value
util:index-key-occurrences
Return the number of occurrences for an indexed value.
- Parameters:
-
$nodes* The nodes whose content is indexed $value The indexed value to search for $index The index in which the search is made - Returns:
- xs:integer? : the number of occurrences for the indexed value
util:index-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.
- Parameters:
-
$node-set* The node set $start-value? Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. $function-reference The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. $max-number-returned? The maximum number of returned keys - Returns:
- item()* : the results of the eval of the $function-reference
util:index-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- Parameters:
-
$node-set* The node set $start-value? Only index keys of the same type but being greater than $start-value will be reported for non-string types. For string types, only keys starting with the given prefix are reported. $function-reference The function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. $max-number-returned? The maximum number of returned keys $index The index in which the search is made - Returns:
- item()* : the results of the eval of the $function-reference
util:index-keys-by-qname
Can be used to query existing range indexes defined on a set of nodes. All index keys defined for the given node set are reported to a callback function. The function will check for indexes defined on path as well as indexes defined by QName.
- Parameters:
-
$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:
- item()* : the results of the eval of the $function-reference
util:index-type
Returns the range index type for a set of nodes or an empty sequence if no index is defined.
- Parameters:
-
$set-of-nodes* The set of nodes - Returns:
- xs:string? : the range index type
util:inspect-function
Returns an XML fragment describing the function referenced by the passed function item.
- Parameters:
-
$function The function item to inspect - Returns:
- node() : the signature of the function
util:int-to-octal
Converts an int e.g. 511 to an octal number e.g. 0777.
- Parameters:
-
$int The int to convert to an octal string. - Returns:
- xs:string
util:integer-to-base
Converts the xs:integer $number (unsigned) into base $base as xs:string. Bases 2, 8, and 16 are supported.
- Parameters:
-
$number The number to convert $base The base of $number - Returns:
- xs:string : the xs:string representation of $number in base $base
util:is-binary-doc
Checks if the resource identified by $binary-resource is a binary resource.
- Parameters:
-
$binary-resource? The path to the binary resource - Returns:
- xs:boolean : true if the resource is a binary document
util:is-module-mapped
Returns a Boolean value if the module statically mapped to a source location in the configuration file.
- Parameters:
-
$namespace-uri The namespace URI of the module - Returns:
- xs:boolean : true if the namespace URI is mapped as an active function module
util:is-module-registered
Returns a Boolean value if the module identified by the namespace URI is registered.
- Parameters:
-
$namespace-uri The namespace URI of the module - Returns:
- xs:boolean : true if the namespace URI is registered as an active function module
util:list-functions
Returns a sequence of function items for each function in the current module.
- Returns:
- function* : sequence of function references
- Deprecated:
- Moved to the module: http://exist-db.org/xquery/inspection, you should now use 'inspect:module-functions' instead! This function could be removed in the next major release version.
util:list-functions
Returns a sequence of function items for each function in the specified module.
- Parameters:
-
$namespace-uri The namespace URI of the function module - Returns:
- function* : sequence of function references
- Deprecated:
- Moved to the module: http://exist-db.org/xquery/inspection, you should now use 'inspect:module-functions' instead! This function could be removed in the next major release version.
util:log
Logs the message to the current logger.
- Parameters:
-
$priority The logging priority: 'error', 'warn', 'debug', 'info', 'trace' $message* The message to log - Returns:
- item()
util:log-app
Logs the message to the named logger
- Parameters:
-
$priority The logging priority: 'error', 'warn', 'debug', 'info', 'trace' $logger-name The name of the logger, eg: my.app.log $message* The message to log - Returns:
- item()
util:log-system-err
Logs the message to System.err.
- Parameters:
-
$message* The message to log - Returns:
- item()
util:log-system-out
Logs the message to System.out.
- Parameters:
-
$message* The message to log - Returns:
- item()
util:map-module
Map the module to a source location. This function is only available to the DBA role.
- Parameters:
-
$namespace-uri The namespace URI of the module $location-uri The location URI of the module - Returns:
- item() : Returns an empty sequence
util:mapped-modules
Returns a sequence containing the namespace URIs of all XQuery modules which are statically mapped to a source location in the configuration file. This does not include any built in modules.
- Returns:
- xs:string+ : the sequence of all of the active function modules namespace URIs
util:node-by-id
Retrieves a node by its internal node-id. The document is specified via the first argument. It may either be a document node or another node from the same document from which the target node will be retrieved by its id. The second argument is the internal node-id, specified as a string. Please note: the function does not check if the passed id does really point to an existing node. It just returns a pointer, which may thus be invalid.
- Parameters:
-
$document The document whose node is to be retrieved by its id $node-id The internal node id - Returns:
- node() : the node
util: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.
- Parameters:
-
$node The node to get the internal node-id from - Returns:
- xs:string : the internal node-id
util:node-xpath
Returns the XPath for a Node.
- Parameters:
-
$node The node to retrieve the XPath to - Returns:
- xs:string? : the XPath expression of the node
util:octal-to-int
Converts an octal string e.g. '0777' to an int e.g. 511.
- Parameters:
-
$octal The octal string to convert to an int. - Returns:
- xs:int
util:parse
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. If the XML is not well-formed, the function throws an error (EXXQDY0002). An XML-formatted description of the error is contained in the error value and can be accessed using XQuery 3.0 try-catch statement.
- Parameters:
-
$to-be-parsed? The string to be parsed - Returns:
- document-node()? : the XML fragment parsed from the string
util:parse-html
Parses the passed string value into an XML fragment. The HTML string may not be well-formed XML. It will be passed through the Neko HTML parser to make it well-formed. An empty sequence is returned if the argument is an empty string or sequence.
- Parameters:
-
$to-be-parsed? The string to be parsed - Returns:
- document-node()? : the XML fragment parsed from the string
util:qname-index-lookup
Can be used to query existing qname indexes defined on a set of nodes.
- Parameters:
-
$qname The QName $comparison-value The comparison value - Returns:
- node()* : the result
util:random
Returns a random number between 0.0 and 1.0
- Returns:
- xs:double : a random number between 0.0 and 1.0
util:random
Returns a random number between 0 (inclusive) and $max (exclusive), that is, a number greater than or equal to 0 but less than $max
- Parameters:
-
$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:
- xs:integer : a random number between 0 and $max
util:random-ulong
Returns a random number between 0 and the maximum xs:unsignedLong
- Returns:
- xs:unsignedLong : a random number between 0 and the maximum xs:unsignedLong
util:registered-functions
Returns a sequence containing the QNames of all functions currently known to the system, including functions in imported and built-in modules.
- Returns:
- xs:string+ : the sequence of function names
util:registered-functions
Returns a sequence containing the QNames of all functions declared in the module identified by the specified namespace URI. An error is raised if no module is found for the specified URI.
- Parameters:
-
$namespace-uri The namespace URI of the function module - Returns:
- xs:string+ : the sequence of function names
util:registered-modules
Returns a sequence containing the namespace URIs of all modules currently known to the system, including built in and imported modules.
- Returns:
- xs:string+ : the sequence of all of the active function modules namespace URIs
util:serialize
Returns the Serialized node set passed in parameter $node-set. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from.
- Parameters:
-
$node-set* The node set to serialize $parameters* The serialization parameters: either a sequence of key=value pairs or an output:serialization-parameters element as defined by the standard fn:serialize function. - Returns:
- xs:string? : the string containing the serialized node set.
util:serialize
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.
- Parameters:
-
$* $* $ $ $* $* - Returns:
- xs:boolean?
- Deprecated:
- Use the file:serialize() function in the file extension module instead! This function could be removed in the next major release version.
util:string-to-binary
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.
- Parameters:
-
$encoded-string? The string containing the encoded binary resource - Returns:
- xs:base64Binary? : the binary resource
util:string-to-binary
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.
- Parameters:
-
$encoded-string? The string containing the encoded binary resource $encoding the encoding type. i.e. 'UTF-8' - Returns:
- xs:base64Binary? : the binary resource
util:system-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:
- xs:date : the current xs:date (with timezone)
util:system-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:
- xs:dateTime : the current xs:dateTime (with timezone)
util:system-property
Returns the value of a system property. Similar to the corresponding XSLT function. Predefined properties are: vendor, vendor-url, product-name, product-version, product-build, and all Java system properties.
- Parameters:
-
$property-name The name of the system property to retrieve the value of. - Returns:
- xs:string? : the value of the named system property
util:system-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:
- xs:time : the current xs:time (with timezone)
util:unescape-uri
Returns an un-escaped URL escaped string with the encoding scheme (e.g. "UTF-8"). Decodes encoded sensitive characters from a URL, for example "%2F" becomes "/", i.e. does the oposite to escape-uri()
- Parameters:
-
$escaped-string The escaped string to be un-escaped $encoding The encoding scheme to use in the un-escaping of the string - Returns:
- xs:string : the un-escaped string
util:unmap-module
Remove relation between module namespace and source location. This function is only available to the DBA role.
- Parameters:
-
$namespace-uri The namespace URI of the module - Returns:
- item() : Returns an empty sequence
util:uuid
Generate a version 4 (random) universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6
- Returns:
- xs:string : a generated UUID string
util:uuid
Generate a version 3 universally unique identifier (UUID) string, e.g. 2b92ddb6-8e4e-3891-b519-afa1609ced73
- Parameters:
-
$name The input value for UUID calculation. - Returns:
- xs:string : a generated UUID string
util:wait
Wait for the specified number of milliseconds
- Parameters:
-
$interval Number of milliseconds to wait. - Returns:
- item() : Returns an empty sequence