I have a few working XQuery scripts that I would like to use to generate valid XML documents. Therefore I would also like to include an XML header: <?xml version="1.0" encoding="UTF-8"?>
. I am aware that this header is optional but I want it to be included regardless, especially to specify the right encoding.
However, I'm at a loss as to how I would insert this header into the output. My editor (XMLSpy) complains on any variation I can think of to insert the header.
According to the few resources I've found on this, it may be that I'm not supposed to generate this header manually, but rather let my serializer do this for me, possibly by setting interpreter options with declare option
. I can't find any information on this when it comes to XMLSpy however.
Is there a way to insert this header manually? If not, do I need to modify my interpreter so it is generated automatically?
Presuming you're using AltovaXML for executing your xquery, you need to set omitXMLDeclaration
to false (the default is true) through whatever interface you're executing it with - command line, java, or whatever. There does not appear to be a xquery-level option declaration to set this. The docs at http://manual.altova.com/AltovaXML/altovaxmlcommunity/ show how to do it for each of the various cases.