1

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.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
David K
  • 213
  • 1
  • 2
  • 12

1 Answers1

1

Output Serialization Options

Generally, there are two options for declaring the output serialization parameters (I simplified the query):

Export Serialization Options

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

http://localhost:8984/rest?query=db:export(%22foo%22,%20%22/tmp%22,%20map%20{%20%27omit-xml-declaration%27:%20%27no%27%20})

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
  • Thank you very much for your help and your edits to my original question. A quick followup: do you know if it is possible to have a line break inserted after the declaration so that the next element appears on the line below the xml declaration? If not, no worries. Thanks again @Jens Erat – David K Jul 10 '15 at 12:29
  • I had a chat with the BaseX project lead today and this was [recorded as a minor bug](https://github.com/BaseXdb/basex/issues/1174). Follow the issue if you're interested in updates. – Jens Erat Jul 16 '15 at 12:33