Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-206

[configuration] DTD validation on loading xml based configurations

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      Both XMLConfiguration and HierarchicalXMLConfiguration should support validation
      of the XML configuration file against a DTD.

      I would suggest adding a setter to allow the user to set an EntityResolver
      before load is called. commons-configuration should apply the EntityResolver if
      set, and supply a log-reporting ErrorHandler.

      Since XMLConfiguration and HierarchicalXMLConfiguration do not share code for
      XML file loading (shouldn't they?), the enhancement must be added to both classes.

        Activity

        Hide
        Oliver Heger added a comment -

        XMLConfiguration now provides a method setDocumentBuilder(), which allows to set
        a custom DocumentBuilder.

        This should be a generic way for resolving this issue. I didn't want to add XML
        parser specific initialization methods like setEntityResolver() or
        setErrorHandler() to XMLConfiguration. Supporting a custom builder allows for
        more flexibility including setting parser specific properties.

        Any comments?

        Show
        Oliver Heger added a comment - XMLConfiguration now provides a method setDocumentBuilder(), which allows to set a custom DocumentBuilder. This should be a generic way for resolving this issue. I didn't want to add XML parser specific initialization methods like setEntityResolver() or setErrorHandler() to XMLConfiguration. Supporting a custom builder allows for more flexibility including setting parser specific properties. Any comments?
        Hide
        Oliver Heger added a comment -

        A setValidating() method was added to XMLConfiguration which provides an easy
        way to enable DTD validation. If the validating flag is set and no custom
        DocumentBuilder is provided, a default DocumentBuilder is used that throws an
        exception in its error() method.

        So I think, support for validation should be quite complete now. I am closing
        this issue. Please reopen if there are further suggestions.

        Show
        Oliver Heger added a comment - A setValidating() method was added to XMLConfiguration which provides an easy way to enable DTD validation. If the validating flag is set and no custom DocumentBuilder is provided, a default DocumentBuilder is used that throws an exception in its error() method. So I think, support for validation should be quite complete now. I am closing this issue. Please reopen if there are further suggestions.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ørjan Austvold
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development