[ 
https://issues.apache.org/jira/browse/CONFIGURATION-585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14067924#comment-14067924
 ] 

Martin Gainty commented on CONFIGURATION-585:
---------------------------------------------

the dev is relying on Hardcoded Parameters here:
if factory.setValidating(true); //why is this hardcoded?
{
   if (isSchemaValidation()) //another hardcoded parameter?
    else BLOW UP 
   }
}
when I ran the library locally all of the testcases failed or produced 
errors..I found this
    /**
     * Returns the root node of this hierarchical configuration. This method
     * exists for backwards compatibility only. New code should use the
     * {@link #getRootNode()} method instead, which operates on
     * the preferred data type {@code ConfigurationNode}.
     *
     * @return the root node
     */
    public org.w3c.dom.Node getRoot()
    { .... }
}
in other words you are relying on every entity read in to be a XML dom document 
which of course
most of them are not ..which testcases produce the most errors?
1)any testcase reading and parsing properties
2)any testcase reading and parsing Database reads
3)any testcase reading and parsing non DOM xml Docs (e.g. Sax OR stax)
I was an enthusistic supporter of (throw anything at your project and we can 
read it)
BUT you have one parse which is for DOM..anything else fails
to get a better understanding read the AXIOM code to see how they handle XML 
documents 
DOM, SAX and STAX (they dont touch properties or database reads)
for now I think a re-architecture is the only solution which will accomodate
1)SomeKindOfPropertyNode which will read and properly parse properties files 
and maintain hierarchy
2)SomeKindOfDBNode which will read and properly parse DB reads and organise 
into a hierarchy
3)SomeKindOfXMLSaxNode which will read and properly parse SAX docs and maintain 
hierarchy
4)SomeKindOfXMLStaxNode Which will read and properly parse STAX docs and 
maintain hierarchy
Martin
20 July 2014



> Hardcoded Parameters prevents correct initialisation of XML DocumentBuilder
> ---------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-585
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-585
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 1.8
>         Environment: JDK 1.7.0.45
> MvN 3.0.5
>            Reporter: Martin Gainty
>            Priority: Blocker
>              Labels: XMLConfiguration
>             Fix For: 2.0
>
>   Original Estimate: 96h
>  Remaining Estimate: 96h
>
> XMLConfiguration:
>  protected DocumentBuilder createDocumentBuilder()
>             throws ParserConfigurationException
>     {
>         if (getDocumentBuilder() != null)
>         {
>             return getDocumentBuilder();
>         }
>         else
>         {
>             DocumentBuilderFactory factory = DocumentBuilderFactory
>                     .newInstance();
>             if (isValidating())
>             {
>                 factory.setValidating(true);
>                 if (isSchemaValidation())
>                 {
>                     factory.setNamespaceAware(true);
>                     factory.setAttribute(JAXP_SCHEMA_LANGUAGE, 
> W3C_XML_SCHEMA);
>                 }
>             }
>             DocumentBuilder result = factory.newDocumentBuilder();
>             result.setEntityResolver(this.entityResolver);
>             if (isValidating())
>             {
>                 // register an error handler which detects validation errors
>                 result.setErrorHandler(new DefaultHandler()
>                 {
>                     @Override
>                     public void error(SAXParseException ex) throws 
> SAXException
>                     {
>                         throw ex;
>                     }
>                 });
>             }
>             return result;
>         }
>     }
> There is no way to externally set any of these parameters
> I propose 2 changes
> 1)read properties from pom.xml
> 2)morph this into a XMLConfigurationPlugin which will run goal to set the 
> params from configuration for new commons-configuration-plugin
> (Bug originally reported by Ron DiFrango from CapitalOne)
> Martin Gainty
> 11 July 2014



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to