Dear Regine,
Welcome to the list.
I'm running an XQuery Update using BaseX from the command line over an XML document, and I want the XML declaration to be preserved. My input is:
basex -uVwsomit-xml-declaration=no <input xQuery Update file>
In BaseX, all XML documents are stored without XML declaration.
However, I was surprised indeed that the declaration is not added in your example during serializtion, and I found out that it’s due to our current default serialization method ('basex'), which ignores this option (similar to the 'adaptive' method that has been added with XQuery 3.1 [1]). The following query works:
basex -somit-xml-declaration=no -smethod=xml "<x/>"
I would call this a bug, as it’s not the behavior most people would expect, and we’ll try to fix it soon [2].
Thanks for the report, Christian
[1] https://www.w3.org/TR/xslt-xquery-serialization-31/#adaptive-output [2] https://github.com/BaseXdb/basex/issues/1369
That looks correct to me per the documentation, but when I run it, I lose the XML declaration nevertheless. (The xQuery Update executes correctly.) I've tried the following, all to no avail:
--split out the -s flag, putting it as the first and last flag, respectively --setting the value to "yes" (well, I knew that wasn't going to work, but I had to check, right?) --upper case NO (ditto...) --adding the following two lines to my xQuery file: declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:omit-xml-declaration "no";
I know this question has come up before, but I couldn't find an approach that worked for me in the list archives. Obviously, at this point I'm just throwing darts at the problem. I'd be grateful for any pointers!
Sincerely,
Regine Heberlein Principal Cataloger and Metadata Analyst, Rare Book Collections Princeton University Library One Washington Road Princeton, NJ 08540 609-258-6156