- All Modules
- All Functions
-
www.w3.org
- 2005
- XDM
- store
- introspection
- reflection
- external
-
xqdoc
-
xqdoc
(E)
-
project_xqdoc
- xqdoc2xhtml
-
xqdoc
(E)
- data processing
- expath.org
- www.functx.com
- Zorba
- debugger
- error
- jsoniq.org
- www.zorba-xquery.com
http://www.zorba-xquery.com/modules/xqxq
import module namespace xqxq = "http://www.zorba-xquery.com/modules/xqxq";
This module contains functions to compile and evaluate XQuery programs. Also, it contains function that allow to parameterize the static or dynamic evaluation phase.
Juan Zacarias
xquery version "3.0" encoding "utf-8";
The latest version of this module is 2.0. For more information about module versioning in Zorba please check out this resource.
- the XQuery module can be found here.
an | http://www.zorba-xquery.com/annotations |
f | http://www.zorba-xquery.com/features |
op | http://www.zorba-xquery.com/options/features |
ver | http://www.zorba-xquery.com/options/versioning |
xqxq | http://www.zorba-xquery.com/modules/xqxq |
![]() ![]() |
bind-context-item
(
$query-key as xs:anyURI,
$dot as item()
) as empty-sequence() This function binds the context-item of the prepared query identified by the given key to the $dot argument. |
![]() ![]() |
bind-variable
(
$query-key as xs:anyURI,
$var as xs:QName,
$value as item()*
) as empty-sequence() This function binds the variable with name $name of the prepared query identified by $query-key to the given sequence. |
![]() ![]() |
delete-query
(
$query-key as xs:anyURI
) as empty-sequence() Deletes the prepared query associated with the given identifier. |
![]() |
evaluate
(
$query-key as xs:anyURI
) as item()* Evaluates the given prepared query and returns the result of the evaluation. |
![]() ![]() |
evaluate-sequential
(
$query-key as xs:string
) as item()* Evaluates the given prepared query and returns the result of the evaluation. |
![]() ![]() |
evaluate-updating
(
$query-key as xs:anyURI
) as Evaluates the given prepared query and applies the updates computed by this query. |
![]() |
external-variables
(
$query-key as xs:anyURI
) as xs:QName* The function returns the names of the external variables that are declared in the given query (either in the main module or in any of the imported library modules). |
![]() |
is-bound-context-item
(
$query-key as xs:anyURI
) as xs:boolean The function tests if the context-item is bound for the execution of the query referred to by the given query identifier. |
![]() |
is-bound-variable
(
$query-key as xs:anyURI,
$var-name as xs:QName
) as xs:boolean The function tests if the given variable is bound for the execution of the query referred to by the given query identifier. |
![]() |
is-sequential
(
$query-key as xs:anyURI
) as xs:boolean The function tests if the query identified by the given key is sequential query. |
![]() |
is-updating
(
$query-key as xs:anyURI
) as xs:boolean The function tests if the query identified by the given key is an updating query. |
![]() |
load-from-query-plan
(
$plan as xs:base64Binary
) as xs:anyURI The function loads a given XQuery program for execution from a xs:base64Binary query plan, obtained through the xqxq:query-plan function. |
![]() |
load-from-query-plan
(
$plan as xs:base64Binary,
$resolver as item()?,
$mapper as item()?
) as xs:anyURI The function loads a given XQuery program for execution from a xs:base64Binary query plan, obtained through the xqxq:query-plan function. |
![]() ![]() |
prepare-library-module
(
$library-module-text as xs:string
) as empty-sequence() This function compiles a given XQuery library module. |
![]() ![]() |
prepare-main-module
(
$main-module-text as xs:string
) as xs:anyURI The function prepares a given XQuery program for execution. |
![]() ![]() |
prepare-main-module
(
$main-module-text as xs:string,
$resolver as item()?,
$mapper as item()?
) as xs:anyURI The function prepares a given XQuery program for execution. |
![]() |
query-plan
(
$query-key as xs:anyURI
) as xs:base64Binary Returns the compiled query identified by the given query-key as binary data. |
![]() |
variable-value
(
$query-key as xs:anyURI,
$var-name as xs:QName
) as item()* This function returns the value of a variable that is bound in the given query. |
declare function xqxq:bind-context-item ( $query-key as xs:anyURI, $dot as item() ) as empty-sequence()
This function binds the context-item of the prepared query identified by the given key to the $dot argument.
- $query-key the identifier for a compiled query
- $dot the context item to bind
- the function has side effects and returns the empty sequence.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:bind-variable ( $query-key as xs:anyURI, $var as xs:QName, $value as item()* ) as empty-sequence()
This function binds the variable with name $name of the prepared query identified by $query-key to the given sequence.
- $query-key the identifier for a compiled query
- $name the name of the external variable to bind
- $value the sequence to which the external variable $name should be bound
- the function has side effects and returns the empty sequence.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:UndeclaredVariable if the given variable is not declared in the query.
declare function xqxq:delete-query ( $query-key as xs:anyURI ) as empty-sequence()
Deletes the prepared query associated with the given identifier. After the query is deleted, the corresponding identifier should not be used as argument to any of the functions of this module.
- $query-key the identifier for a compiled query
- the function has side effects and returns the empty sequence.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:evaluate ( $query-key as xs:anyURI ) as item()*
Evaluates the given prepared query and returns the result of the evaluation. The query must not be sequential or updating.
- $query-key the identifier for a compiled query
- the result of evaluating the given query
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:QueryIsUpdating if the query is an updating query.
- xqxq:QueryIsSequential if the query is sequential.
- any dynamic error that is raised by evaluating the given query.
declare function xqxq:evaluate-sequential ( $query-key as xs:string ) as item()*
Evaluates the given prepared query and returns the result of the evaluation. The query must be sequential.
- $query-key the identifier for a compiled query
- the result of evaluating the query.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:QueryNotSequential if the query is not sequential.
- xqxq:QueryIsUpdating if the query is an updating query.
- any dynamic error that is raised by evaluating the given query.
declare function xqxq:evaluate-updating ( $query-key as xs:anyURI ) as
Evaluates the given prepared query and applies the updates computed by this query. The query must be an updating query.
- $query-key the identifier for a compiled query
- the function has side effects because it applies the updates of the query. It returns the empty sequence.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:QueryNotUpdating if the query is not an updating query.
- xqxq:QueryIsSequential if the query is sequential.
- any dynamic error that is raised by evaluating the given query or applying its updates.
declare function xqxq:external-variables ( $query-key as xs:anyURI ) as xs:QName*
The function returns the names of the external variables that are declared in the given query (either in the main module or in any of the imported library modules).
- $query-key the identifier for a compiled query
- the sequence of names of the said external variables.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:is-bound-context-item ( $query-key as xs:anyURI ) as xs:boolean
The function tests if the context-item is bound for the execution of the query referred to by the given query identifier.
- $query-key the identifier for a compiled query
- true if the context-item is bound, false otherwise.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:is-bound-variable ( $query-key as xs:anyURI, $var-name as xs:QName ) as xs:boolean
The function tests if the given variable is bound for the execution of the query referred to by the given query identifier.
- $query-key the identifier for a compiled query
- $var-name the name of the variable
- true if the variable is bound, false otherwise.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:UndeclaredVariable if the given variable is not declared in the query.
declare function xqxq:is-sequential ( $query-key as xs:anyURI ) as xs:boolean
The function tests if the query identified by the given key is sequential query.
- $query-key the identifier for a compiled query
- true if the query is a sequential, false otherwise.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:is-updating ( $query-key as xs:anyURI ) as xs:boolean
The function tests if the query identified by the given key is an updating query.
- $query-key the identifier for a compiled query
- true if the query is an updating query, false otherwise.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
declare function xqxq:load-from-query-plan ( $plan as xs:base64Binary ) as xs:anyURI
The function loads a given XQuery program for execution from a xs:base64Binary query plan, obtained through the xqxq:query-plan function. If the program was successfully loaded, the function returns an identifier as xs:anyURI. This URI can be passed to other functions of this module (e.g. to actually evaluate the program). The URI is opaque and its lifetime is bound by the lifetime of the XQuery program that invoked this function. Further reference or uses of the identifier lead to unexpected results. Successfully prepared queries need to be deleted by passing the resulting identifier to the xqxq:delete-query function of this module.
- $main-module-text the XQuery program that should be prepared. The program needs to be a XQuery main module.
- an identifier for the compiled program that can be passed as arguments to other functions of this module.
- any (static or type) error that may be raised during the compilation of the query. For example, err:XPST0003 if the given XQuery program could not be parsed.
declare function xqxq:load-from-query-plan ( $plan as xs:base64Binary, $resolver as item()?, $mapper as item()? ) as xs:anyURI
The function loads a given XQuery program for execution from a xs:base64Binary query plan, obtained through the xqxq:query-plan function. If the program was successfully loaded, the function returns an identifier as xs:anyURI. This URI can be passed to other functions of this module (e.g. to actually evaluate the program). The URI is opaque and its lilfetime is bound by the lifetime of the XQuery program that invoked this function. Further reference or uses of the identifier lead to unexpected results. For important notes regarding the second and third parameters of the function, review the comments in xqxq:prepare-main-module#3. Successfully prepared queries need to be deleted by passing the resulting identifier to the xqxq:delete-query function of this module.
- $main-module-text the XQuery program that should be prepared. The program needs to be a XQuery main module.
- $resolver the URL resolver function.
- $mapper the URI mapper function.
- an identifier for the compiled program that can be passed as arguments to other functions of this module.
- any (static or type) error that may be raised during the compilation of the query. For example, err:XPST0003 if the given XQuery program could not be parsed.
declare function xqxq:prepare-library-module ( $library-module-text as xs:string ) as empty-sequence()
This function compiles a given XQuery library module. It can be used to compile-check a module.
- $library-module-text the XQuery library module that should be prepared.
- the function is declared as sequential.It returns the empty-sequence.
- any (static or type) error that may be raised during the compilation of the library module. For example, err:XPST0003 if the given XQuery library module could not be parsed.
declare function xqxq:prepare-main-module ( $main-module-text as xs:string ) as xs:anyURI
The function prepares a given XQuery program for execution. If the program was successfully compiled, the function returns an identifier as xs:anyURI. This URI can be passed to other functions of this module (e.g. to actually evaluate the program). The URI is opaque and its lilfetime is bound by the lifetime of the XQuery program that invoked this function. Further reference or uses of the identifier lead to unexpected results. Successfully prepared queries need to be deleted by passing the resulting identifier to the xqxq:delete-query function of this module.
- $main-module-text the XQuery program that should be prepared. The program needs to be a XQuery main module.
- an identifier for the compiled program that can be passed as arguments to other functions of this module.
- any (static or type) error that may be raised during the compilation of the query. For example, err:XPST0003 if the given XQuery program could not be parsed.
declare function xqxq:prepare-main-module ( $main-module-text as xs:string, $resolver as item()?, $mapper as item()? ) as xs:anyURI
The function prepares a given XQuery program for execution. If the program was successfully compiled, the function returns an identifier as xs:anyURI. This URI can be passed to other functions of this module (e.g. to actually evaluate the program). The URI is opaque and its lilfetime is bound by the lifetime of the XQuery program that invoked this function. Further reference or uses of the identifier lead to unexpected results. Important notes regarding the second and third parameters of the function: -------------------------------------------------------------------------- These parameters allow you to specify a URL resolver and a URI mapper for Zorba to use when executing this query. See http://www.zorba-xquery.com/html/documentation/2.7.0/zorba/uriresolvers The second parameter is a function item for a URL resolver. The URL resolver function must recive 2 parameters: A $namespace as xs:string that will contain the url to be resolved. A $entity as xs:string that will contain the type of resolving needed; this can be 2 values "module" and "schema". The function must return an empty sequence when the specified $namespace or $entity are not the ones to be resolved. Example: declare function mymod:url-resolver($namespace as xs:string, $entity as xs:string) { if($namespace = 'http://test.xq') then "module namespace test = 'http://test'; declare function test:foo(){'foo'};" else () }; The URL resolver function's namespace, name, and parameter naming are not restricted by XQXQ. The URL resolver function's return type is not restricted, it could be a string, a sequence, a node, etc. All the outputs types are to be serialized as a string. The third parameter is a function item for a URI mapper. The URI mapper function, just like the URL resolver, receives 2 parameters: A $namespace as xs:string that will contain the URI to be mapped. A $entity as xs:string that will contain the type of resolving needed; this can be 2 values "module" and "schema". The URI mapper must return an empty sequence when the specified $namesapce or $entity are not to be mapped. Unlike the URL resolver this function must return a sequence of strings. Example: declare function mymod:uri-mapper($namespace as xs:string, $entity as xs:string) { if($namespace = 'http://test') then ("http://www.zorba-xquery.com/test", "http://foo.com/schema/test") else () }; The URI mapper function's namespace, name, and parameter naming are not restricted by XQXQ. In order to pass the above URL resolver and URI mapper to this function, use the following syntax: variable $queryID := xqxq:prepare-main-module("..query text..", mymod:url-resolver#2, mymod:uri-mapper#2); That is, the QName of the function followed by "#2". This is XQuery "higher-order function" syntax, meaning the function with the specified QName which takes two arguments. Since URL resolvers and URI mappers must take two arguments, both will always be specified with "#2". Note that parameters 2 and 3 should be declared as follows: as function($url as xs:string, $entity as xs:string) as item() as function($uri as xs:string, $entity as xs:string) as xs:string* However Zorba's implementation of higher-order functions (HOF) is not yet complete enough to allow for this. When Zorba's HOF implementation is complete this function signature will be changed. Both the URL resolver and URI mapper functions are optional, meaning you may pass the empty-sequence () for either. Successfully prepared queries need to be deleted by passing the resulting identifier to the xqxq:delete-query function of this module.
- $main-module-text the XQuery program that should be prepared. The program needs to be a XQuery main module.
- $resolver the URL resolver function.
- $mapper the URI mapper function.
- an identifier for the compiled program that can be passed as arguments to other functions of this module.
- any (static or type) error that may be raised during the compilation of the query. For example, err:XPST0003 if the given XQuery program could not be parsed.
declare function xqxq:query-plan ( $query-key as xs:anyURI ) as xs:base64Binary
Returns the compiled query identified by the given query-key as binary data.
- $query-key the identifier of a compiled query.
- the query as xs:base64Binary.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:QueryPlanError if there is an error serializing the query.
declare function xqxq:variable-value ( $query-key as xs:anyURI, $var-name as xs:QName ) as item()*
This function returns the value of a variable that is bound in the given query.
- $query-key the identifier of a compiled query.
- $var-name the name of the variable whose value should be returned.
- the value bound to the given variable.
- xqxq:NoQueryMatch if no query with the given identifier was prepared.
- xqxq:UndeclaredVariable if the given variable is not declared in the query.
- xqxq:UnboundVariable if the given variable doesn't have a value.