Hi Mike,
a) Is it possible to disable the addition of the xmlns attribute?
XQuery (Update) provides no single function or expression to rename or drop namespaces, but you can easily do that by recursively rebuilding your document without namespaces:
declare function local:strip-ns($n as node()) as node() { if($n instance of element()) then ( element { local-name($n) } { $n/@*, $n/node()/local:strip-ns(.) } ) else if($n instance of document-node()) then ( document { local:strip-ns($n/node()) } ) else ( $n ) };
let $xml := document { <items xmlns="http://server.my.org/xyz"> <item>Stuff1</item> <item>Stuff2</item> </items> } return local:strip-ns($xml)
As REST results cannot be post-processed in the very same step, you will be more flexible with a RESTXQ facade.
b) Is it possible to include the prefix in the xmlns attribute being appended to the root element?
I’m not sure what you mean by this alternative. Would you like to have rebound the namespace to a prefix?
<xyz:items xmlns:xyz="http://server.my.org/xyz%22%3E ...
The answer would be the same: A recursive XQuery function will do the job.
If this all sounds too cumbersome, and if you never work with namespaces anyway, you can already strip all namespaces when adding documents to a database via the STRIPNS option [1].
Hope this helps, Christian