Changes

Jump to navigation Jump to search
41 bytes removed ,  14:24, 27 February 2020
no edit summary
==xquery:eval==
 
{{Mark|Updated with 9.2}}: First argument can be a URI (xquery:invoke was removed).
{| width='100%'
* {{Code|xquery:eval("1+3")}} returns {{Code|4}}.<br />
* If a URI is supplied, the query in the specified file will be evaluated:
<pre classsyntaxhighlight lang='brush:"xquery'">
xquery:eval(xs:anyURI('cleanup.xq'))
</presyntaxhighlight>
* You can bind the context and e.g. operate on a certain database only:<br />
<pre classsyntaxhighlight lang='brush:"xquery'">
xquery:eval("//country", map { '': db:open('factbook') })
</presyntaxhighlight>
* The following expressions use strings as keys. All of them return 'XML':<br/>
<pre classsyntaxhighlight lang='brush:"xquery'">
xquery:eval(".", map { '': 'XML' }),
map { '{URI}xml': 'XML' }
)
</presyntaxhighlight>
* The following expressions use QNames as keys. All of them return 'XML':<br/>
<pre classsyntaxhighlight lang='brush:"xquery'">
declare namespace pref = 'URI';
let $vars := map { xs:QName('pref:xml'): 'XML' }
return xquery:eval($query, $vars)
</presyntaxhighlight>
|}
==xquery:eval-update==
 
{{Mark|Updated with 9.2}}: First argument may be a URI (xquery:invoke-update was removed).
{| width='100%'
|
* Removes entries from a temporary databases and returns an info string:
<pre classsyntaxhighlight lang="brush:xquery">
xquery:eval-update("
delete node db:open('tmp')/*,
update:output('TEMPORARY DATABASE WAS CLEANED UP')
")
</presyntaxhighlight>
|}
|
* {{Code|xquery:parse("1 + 3")}} returns:
<pre classsyntaxhighlight lang='brush:"xml'">
<MainModule updating="false">
<QueryPlan compiled="false">
</QueryPlan>
</MainModule>
</presyntaxhighlight>
|}
|
* The following function sleeps in parallel; it will be finished in 1 second if your system has at least 2 cores:
<pre classsyntaxhighlight lang='brush:"xquery'">
let $f := function() { prof:sleep(1000) }
return xquery:fork-join(($f, $f))
</presyntaxhighlight>
* In the following query, up to four URLs will be requested in parallel:
<pre classsyntaxhighlight lang='brush:"xquery'">
xquery:fork-join(
for $segment in 1 to 4
return function() { http:send-request((), $url) }
)
</presyntaxhighlight>
|-
|'''Errors'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu