I have been using BaseX and REST for a few months now to play around with some XML files. Up to this point I have been exporting my files using the query:
db:export(',char(39),dbName,char(39),',',char(34),'path',char(34),')
If this is confusing, it is just because I am showing how it is constructed, the actual call looks like:
http://localhost:8984/rest?query=db%3Aexport%28%27dbName%27%2C%22C%3A%5CUsers%5Cdak52%5CDocuments%5Cfolder%22%29
Anyways, this works just fine, but I want to include the XML declaration in my output. I have tried setting the omit-xml-declaration
option to "no" but I guess I am not doing it correctly. It works fine when I try to export from the BaseX GUI specifying that option, but I want to do it all via REST, and that is where I am having problems. Below is my query with the option included.
http://localhost:8984/rest?query=db%3Aexport%28%27dbName%27%2C%22C%3A%5CUsers%5Cdak52%5CDocuments%5Cfolder%22%29&omit-xml-declaration=no
This runs and generates output, but this output does not include my xml declaration.
Generally, there are two options for declaring the output serialization parameters (I simplified the query):
In the query prolog (declare option output:omit-xml-declaration "no";
):
As a REST GET (or also POST) parameter as you have already tried:
http://localhost:8984/rest?query=%3Cfoo/%3E&omit-xml-declaration=yes
The problem is these both set the output serialization options. You need to change the export options instead, as described in the documentation. For a query
db:export("foo", "/tmp", map { 'omit-xml-declaration': 'no' })
use the REST call