Changes

Jump to navigation Jump to search
245 bytes added ,  16:30, 3 November 2023
no edit summary
* {{Code|query}}: Evaluate an XQuery expression. If a database or database path is specified in the URL, it is set as query context.
* {{Code|command}}: Execute a single [[Commands|database command]].
* {{Code|run}}: Evaluate an XQuery file or command script located on the server. The file path is resolved against the directory specified by {{Option|RESTPATH}} (before, it was resolved against {{Option|WEBPATH}})directory. Similar to {{Code|query}}, a database or database path is set as context.
; Examples
</syntaxhighlight>
* Bind value to the {{Code|$person}} variable and run query <code>find-person.xq</code>, which must be located in the directory specified by {{Option|WEBPATH}}:
<syntaxhighlight lang="xml">
<run>
==GET Method==
All query Query parameters that have not been processed before otherwise will be treated as variable assignments:
; Example
* The following request assigns two variables to a server-side query file <code>mult.xq</code> placed in the HTTP directory:<br/><code>http://localhost:8080/rest?run=multmultiply.xq&$a=21&$b=2</code>assigns two variables and invokes <code>multiply.xq</code>:
<syntaxhighlight lang="xquery">
(: XQuery file: multmultiply.xq :)
declare variable $a as xs:integer external;
declare variable $b as xs:integer external;
<mult>{ $a * $b }</mult>
</syntaxhighlight>
 
; Example
 
{{Announce|Updated with Version 11:}} Support for multiple values.
 
The request <code>http://localhost:8080/rest?run=sum.xq&n=3&n=4&n=5</code> assigns multiple values to the same variable:
<syntaxhighlight lang="xquery">
(: XQuery file: sum.xq :)
declare variable $n as xs:integer* external;
sum($n)
</syntaxhighlight>
==POST Method==
If <code>query</code> or <code>run</code> is used as an operation, external variables can be specified via the <code><variable/></code> element:
<syntaxhighlight lang="xml">
=Changelog=
 
;Version 11.0
* Updated: [[#Assigning Variables|Assigning Variables]]: Support for multiple values.
;Version 10.0
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu