I’m trying to read existing xml file, that has duplicated namespace declarations. It is important to me to leave this declarations for further processing. Earlier I was using XERCES implementation of org.w3c.dom api to read such a documents, and all declarations left, but when I started to use JDOM, it started to omit redundant namespace declarations.
Here is the sample xml file:
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:ns="namespace_uri">
<element1>...</element1>
<element2>
<ns:child>
text
</ns:child>
<element3 xmlns:ns="namespace_uri">
<ns:child>
content
</ns:child>
</element3>
</document>
I’m building JDOM Document with this code:
SAXBuilder builder = new SAXBuilder();
File inputXml = new File(inputFile);
jdomInDoc = builder.build(inputXml);
Is there any way to force JDOM not to omit redundant namespace declarations?
Thank you in advance for yor answers.
Currently there is no way in JDOM to leave the redundant namespace declarationa. It is possible, even likely that if you want you can override the XMLOutputter to output the duplicates. I can look in to that.
I have opened issue 83 https://github.com/hunterhacker/jdom/issues/83
This s the sort of thing that can potentially be added to the JDOM Format system
Regardless, I will look in to whether this will be possible in JDOM with customization…