commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claude Warren (JIRA)" <>
Subject [jira] [Commented] (CONFIGURATION-652) FileHandler does not produce root node attributes for XMLConfiguration
Date Fri, 10 Feb 2017 11:05:41 GMT


Claude Warren commented on CONFIGURATION-652:

In XMLConfiguration class line 868 we find    
    private Document createDocument() throws ConfigurationException
            ReferenceNodeHandler handler = getReferenceHandler();
            XMLDocumentHelper docHelper =
                    (XMLDocumentHelper) handler.getReference(handler.getRootNode());
            XMLDocumentHelper newHelper =
                    (docHelper == null) ? XMLDocumentHelper
                        .forNewDocument(getRootElementName()) : docHelper

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:
>             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:
> 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

View raw message