[
https://issues.apache.org/jira/browse/CONFIGURATION-652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15861109#comment-15861109
]
Claude Warren commented on CONFIGURATION-652:
---------------------------------------------
In XMLConfiguration class line 868 we find
{code}
private Document createDocument() throws ConfigurationException
{
ReferenceNodeHandler handler = getReferenceHandler();
XMLDocumentHelper docHelper =
(XMLDocumentHelper)
handler.getReference(handler.getRootNode());
XMLDocumentHelper newHelper =
(docHelper == null) ? XMLDocumentHelper
.forNewDocument(getRootElementName()) : docHelper
.createCopy();
{code}
The {code}XMLDocumentHelper.forNewDocument(){code} creates the new document for
the root element. However, the namespace attributes are attached to the
{code}handler.getRootNode(){code}. I think that the document builder needs the
namespace defined before usage and so the namespace info should be made
available in the {code}XMLDocumentHelper.forNewDocument(){code} method.
Additionally the {code}forNewDocument(){code} method calls {code}Element
rootElem = doc.createElement(rootElementName){code} which does not create a
namespace aware name. To do that {code}doc.createElementNS(){code} method
would need to be called.
> FileHandler does not produce root node attributes for XMLConfiguration
> ------------------------------------------------------------------------
>
> Key: CONFIGURATION-652
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-652
> Project: Commons Configuration
> Issue Type: Bug
> Components: Interpolation
> Affects Versions: 2.1.1
> Environment: Java 8 on Linux
> Reporter: Claude Warren
> Labels: namespace, xml
> Attachments: Test.java
>
>
> I have a case where I need to take a Configuration file and write it as an
> XML document. The document should have one or more xmlns properties on the
> root node but the xmlns attributes are not output.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)