Database Reference
In-Depth Information
query found 3 hits in total, and returned the results starting from index 1 and count‐
ing up to index 3 . The use of start and count should become clearer when we look at
paging shortly. The format of the XML result wrapper is documented in “wrap XML
grammar” on page 540 .
If you do not want eXist to return your data in an exist:result element, you can
turn off wrapping using _wrap=no , as in the following cURL command:
curl "http://localhost:8080/exist/rest/db/people
?_wrap=no&_query=%2Fperson%2Fname"
However, you should note that the XQuery we wrote will return a sequence of name
elements, so the result of the call to the REST Server API will not be a valid XML
document if you turn off wrapping. To resolve this, you could introduce a wrapper
element in your own XQuery, as in:
xquery version "1.0" ;
<names> {
/ person / name
} </names>
After URL encoding, we can now send this XQuery to the REST Server API using the
following cURL command:
curl "http://localhost:8080/exist/rest/db/people
?_wrap=no&_query=%3Cnames%3E%7B%0A++++%2Fperson%2Fname%0A%7D%3C%2Fnames%3E"
which could result in a response similar to:
<names>
<name>
<first-name> John </first-name>
<family-name> Smith </family-name>
</name>
<name>
<first-name> George </first-name>
<family-name> Baker </family-name>
</name>
<name>
<first-name> Barbara </first-name>
<family-name> Jones </family-name>
</name>
</names>
So far, we have just sent very simple queries to the REST Server. While placing the
XQuery in the query parameter of the URL sent to the REST Server API works for
small XQueries, it does not scale particularly well because:
• We have to URL-encode the XQuery that we wish to send, which makes it
unreadable.
Search WWH ::




Custom Search