Monday, May 9, 2011

Using curl with eXist to perform XQuery

Simple trick to use HTTP POST with curl to do an XQuery - (I struggled for a bit with the Content-type)

curl --header "Content-type: text/xml" --data "@x.xml" http://hostname:8080/exist/rest/db/

where x.xml is something like:


<?xml version="1.0" encoding="UTF-8"?>
<query xmlns="http://exist.sourceforge.net/NS/exist" start="1" max="20">
<text>
  <![CDATA[
  some XQuery here...
  ]]>
</text>
<properties>
  <property name="indent" value="yes"/>
</properties>
</query>