Changes

Jump to navigation Jump to search
36 bytes removed ,  00:50, 16 January 2012
m
Text replace - "www.basex.org" to "basex.org"
<pre class="brush:xml">
<rest:databases resources="1" xmlns:rest="http://www.basex.org/rest">
<rest:database resources="1" size="1813599">factbook</rest:database>
</rest:databases>
<pre class="brush:xml">
<rest:database name="factbook" resources="1" xmlns:rest="http://www.basex.org/rest">
<rest:resource type="xml" content-type="application/xml" size="77192">factbook.xml</rest:resource>
</rest:database>
* '''Context''':<br/>The <code>context</code> parameter may be used to provide an initial XML context node.
* '''Serialization''':<br/>All [[Serialization]] parameters known to BaseX can be specified as query parameters. Parameters that are specified within a query will be interpreted by the REST server before the output is generated.
* '''Wrap''':<br/>The <code>wrap</code> parameter encloses all query results with XML elements, using the <code>http://www.basex.org/rest</code> namespace.
==Request Methods==
* The following query returns the first five city names of the <b>factbook</b> database:
<pre class="brush:xml">
<query xmlns="http://www.basex.org/rest">
<text><![CDATA[ (//city/name)[position() <= 5] ]]></text>
</query>
* The second query returns the string lengths of all text nodes, which are found in the node that has been specified as initial context node:
<pre class="brush:xml">
<rest:query xmlns:rest="http://www.basex.org/rest">
<rest:text>for $i in .//text() return string-length($i)</rest:text>
<rest:context>
* The following request returns the registered database users encoded in <code>ISO-8859-1</code>:
<pre class="brush:xml">
<command xmlns="http://www.basex.org/rest">
<text>show users</text>
<parameter name='encoding' value='ISO-8859-1'/>
* The last request runs a query <code>query.xq</code> located in the directory specified by <code>[[Options#HTTPPATH|HTTPPATH]]</code>:
<pre class="brush:xml">
<run xmlns="http://www.basex.org/rest">
<text>query.xq</text>
</run>
<pre class="brush:xml">
<query xmlns="http://www.basex.org/rest">
<text>
declare variable $x as xs:integer external;
:<code>curl -i "admin:admin@localhost:8984/rest/factbook?query=//city/name"</code>
;POST
:<code>curl -i -X POST -H "Content-Type: application/xml" -d <br/> "&lt;query xmlns='<nowiki>http://www.basex.org/rest'</nowiki>&gt;&lt;text&gt;//city/name&lt;/text&gt;&lt;/query&gt;" <br/> "admin:admin@localhost:8984/rest/factbook"</code>
:<code>curl -i -X POST -H "Content-Type: application/xml" -T query.xml "admin:admin@localhost:8984/rest/factbook"</code>
;PUT
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu