Changes

Jump to navigation Jump to search
761 bytes added ,  09:59, 18 August 2018
no edit summary
This [[Module Library|XQuery Module]] contains functions for parsing and evaluating XQuery strings and modules at runtime, and to run code in parallel.
=Conventions=
 
{{Mark|Updated with Version 9.0}}:
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/xquery</nowiki></code> namespace, which is statically bound to the {{Code|xquery}} prefix.<br/>
=FunctionsDynamic Evaluation=
==xquery:eval==
 
{{Mark|Updated with Version 9.0}}: {{code|pass}} option added.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|xquery:eval|$query as xs:string|item()*}}<br />{{Func|xquery:eval|$query as xs:string, $bindings as map(*)?|item()*}}<br />{{Func|xquery:eval|$query as xs:string, $bindings as map(*)?, $options as map(xs:string, xs:string*)?|item()*}}<br />
|-
| '''Summary'''
==xquery:eval-update==
 
{{Mark|Updated with Version 9.0}}: Renamed (old name: xquery:update)
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|xquery:eval-update|$query as xs:string|item()*}}<br />{{Func|xquery:eval-update|$query as xs:string, $bindings as map(*)?|item()*}}<br />{{Func|xquery:eval-update|$query as xs:string, $bindings as map(*)?, $options as map(xs:string, xs:string*)?|item()}}<br />
|-
| '''Summary'''
|-
| width='120' | '''Signatures'''
|{{Func|xquery:invoke|$uri as xs:string|item()*}}<br />{{Func|xquery:invoke|$uri as xs:string, $bindings as map(*)?|item()*}}<br />{{Func|xquery:invoke|$uri as xs:string, $bindings as map(*)?, $options as map(*)?|item()*}}<br />
|-
| '''Summary'''
|-
| '''Errors'''
|{{Error|update|#Errors}} the expression contains [[XQuery Update#Updating Expressions|updating expressions]].<br/>{{Error|permission|#Errors}} insufficient permissions for evaluating the query.<br/>{{Error|BXXQ0004timeout|#Errors}} query execution exceeded timeout.<br/>{{Error|nested|#Errors}} nested query evaluation is not allowed.<br/>Any other error that may occur while evaluating the query.|} ==xquery:invoke-update== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|xquery:invoke-update|$uri as xs:string|item()*}}<br />{{Func|xquery:invoke-update|$uri as xs:string, $bindings as map(*)?|item()*}}<br />{{Func|xquery:invoke-update|$uri as xs:string, $bindings as map(*)?, $options as map(*)?|item()*}}<br />|-| '''Summary'''|Evaluates the updating XQuery module located at {{Code|$uri}} at runtime. A relative URI will be resolved against the static base URI of the query.<br />The rules of the {{Code|$bindings}} and {{Code|$options}} parameters are the same as for [[#xquery:eval|xquery:eval]].|-| '''Errors'''|{{Error|update|#Errors}} the expression contains no [[XQuery Update#Updating Expressions|updating expressions]].<br/>{{Error|permission|#Errors}} insufficient permissions for evaluating the query.<br/>{{Error|timeout|#Errors}} query execution exceeded timeout.<br/>{{Error|nested|#Errors}} nested query evaluation is not allowed.<br/>Any other error that may occur while evaluating the query.
|}
 
=XQuery Parsing=
==xquery:parse==
 
{{Mark|Updated with Version 9.0}}: {{code|base-uri}} option added.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|xquery:parse|$query as xs:string|item()?}}<br />{{Func|xquery:parse|$query as xs:string, $options as map(*)?|item()?}}<br />
|-
| '''Summary'''
==xquery:parse-uri==
 
{{Mark|Updated with Version 9.0}}: {{code|base-uri}} option added.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|xquery:parse-uri|$uri as xs:string|item()?}}<br />{{Func|xquery:parse-uri|$uri as xs:string, $options as map(*)?|item()?}}<br />
|-
| '''Summary'''
=Parallelized Execution=
Parallel query execution is recommendable if you have various calls that require a lot of time, but that cannot be sped up by rewriting the code. This is e. g. the case if external URLs are called. If you are parallelizing local data reads (such as the access to a database), single-threaded queries will usually be faster, because parallelized access to disk data often results in randomized access patterns, which can hardly will rarely be optimized by the caching strategies of HDHDDs, SSDs, SSD or the operating system.
==xquery:fork-join==
* In the following query, up to four URLs will be requested in parallel:
<pre class='brush:xquery'>
let $funcs xquery:=fork-join(
for $segment in 1 to 4
let $url := 'http://url.com/path/' || $segment
return function() { http:send-request((), $url) }
return xquery:fork-join($funcs)
</pre>
|-
=Errors=
 
{{Mark|Updated with Version 9.0}}:
{| class="wikitable" width="100%"
;Version 9.0
* Added: [[#xquery:invoke-update|xquery:invoke-update]]
* Updated: [[#xquery:eval|xquery:eval]]: {{Code|pass}} option added
* Updated: [[#xquery:parse|xquery:parse]], [[#xquery:parse-uri|xquery:parse-uri]]: {{Code|base-uri}} option added
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu