Changes

Jump to navigation Jump to search
1,135 bytes added ,  17:11, 17 October 2017
no edit summary
==POST Method==
The body of a POST request is interpreted as XML fragment, which specifies theoperation to perform. The name of the root element determines how the body must conform to a given will be evaluated: * {{Code|commands}} (new since {{Version|9.0}}!): Run [[REST: POST SchemaCommands#Command Scripts|XML SchemaCommand Script]]* {{Code|query}}: Execute XQuery expression* {{Code|run}}: Run server-side file (query or command script)* {{Code|command}}: Execute single command  With {{Version|9.0}}, the REST namespace of the root element has become optionalExisting command scripts can be sent to the server without any modifications: * Create an empty database and return database information: <pre class="brush:xml"><commands> <create-db name='db'/> <info-db/></commands></pre> For the other commands, the following child elements are supported: {| class="wikitable"|-! Name! Description|-| {{Code|text}}| Required; contains the query string, command string, or file to be run|-| {{Code|parameter}}| Serialization parameter (with {{Code|@name}} and {{Code|@value}} attributes)|-| {{Code|option}}| Database option (with {{Code|@name}} and {{Code|@value}} attributes)|-| {{Code|variable}}| Variable bindings|-| {{Code|context}}| Initial context item|}
; Examples
* The following query returns Return the first five city names of the <b>factbook</b> database:
<pre class="brush:xml">
<rest:query xmlns:rest="http://basex.org/rest"> <rest:text><![CDATA[ (//city/name)[position() <= 5] ]]></rest:text></rest:query>
</pre>
* The second query returns the Return string lengths of all text nodes, which that are found in the node that has been specified as initial context node:
<pre class="brush:xml">
<rest:query xmlns:rest="http://basex.org/rest"> <rest:text>for $i in .//text() return string-length($i)</rest:text> <rest:context>
<xml>
<text>Hello</text>
<text>World</text>
</xml>
</rest:context></rest:query>
</pre>
* The following request returns Return the registered database users encoded in <code>ISO-8859-1</code>:
<pre class="brush:xml">
<command xmlns="http://basex.org/rest">
<text>show users</text>
<parameter name='encoding' value='ISO-8859-1'/>
</pre>
* This example creates Create a new database from the specified input and retains preserve all whitespaces:
<pre class="brush:xml">
<command xmlns="http://basex.org/rest">
<text>create db test http://files.basex.org/xml/xmark.xml</text>
<option name='chop' value='false'/>
</pre>
* The last request runs a Bind value to the {{Code|$person}} variable and run query <code>queryfind-person.xq</code> , which must be located in the directory specified by <code>[[Options#WEBPATH|WEBPATH]]</code>:
<pre class="brush:xml">
<run xmlns> <variable name="http://basex.org'person' value='Johannes Müller'/rest"> <text>queryfind-person.xq</text>
</run>
</pre>
=Changelog=
 
;Version 9.0
* Added: Support for command scripts in the [[#POST Method|POST_Method]].
* Updated: The REST namespace in the [[#POST Method|POST_Method]] has become optional.
;Version 8.1
* Added: support Support for input-specific content-type parameters* Updated: the The [[#GET Method|run operation]] now resolves file paths against the [[Options#RESTPATH|RESTPATH]] option.
;Version 8.0
;Version 7.2
* Removed: direct Direct evaluation of adresses resources with <code>application/xquery</code> as content type
;Version 7.1.1
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu