Allow specifying URI of the default namespace for root element
Although namespace declarations will be automatically written as needed, sometimes it'd be nice to be able to explicitly specify root element namespace binding for the "default" namespace (one with no prefix).
Note that this is similar to #207 but specifically refers to ability to specify desired default namespace URI as opposed to namespace prefix for explicit namespaces.
This would be particularly useful for a scenario where a user has a string of JSON and wishes to convert it to XML with a custom root namespace. My understanding is that I want to read the JSON into an ObjectNode and then use an XmlMapper to output XML. Something like this would be a welcome addition:
String json = "...";
ObjectNode node = objectMapper.readTree(json);
String xml = xmlMapper.writer()
.withRootName("myRootElement")
.withRootNamespace("http://example.org") // or simply .withNamespace("...")
.writeValueAsString(node);
Default namespace handling can be tricky in many ways, but yes, I can see this one use case being one where it'd make sense as JsonNode otherwise will not have namespace information.
Although it does depend a bit on how underlying Stax XmlStreamWriter does things -- if it is aware of default namespace being written, it will then add explicit REMOVAL of namespace declaration for all elements :-(
(as it will match NamespaceURI to use and sees request for "empty" namespace on writeStartElement()).