Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-210

[configuration] Access to top level tag in XMLConfiguration

    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

      When XMLConfiguration is used to write a file the top level tag is always
      <configuration>, it should be possible to provide it with a more suitable tag
      name depending of the file. Also read access would be very useful.

      If fact this was possible before 1.0 rc1, ConfigurationXMLDocument.write() had
      an argument to name the top level tag, and
      HierarchicalDOM4JConfiguration.getRoot() gave read and write access to it.

        Activity

        Hide
        Oliver Heger added a comment -

        Methods getRootElementName() and setRootElementName() have been added to
        XMLConfiguration.

        For new XML documents (i.e. if the configuration was newly created and not
        loaded from a file) it is possible to set the name of the root element. However
        if the configuration was loaded from an XML document, this is not possible
        because I did not find a simple way to change a node's tag name using plain DOM.
        In this case an attempt to change the root name will throw an
        UnsupportedOperationException. This behavior is also explained in the javadocs.

        I am marking this as fixed. If somebody needs a better solution, please reopen.

        Show
        Oliver Heger added a comment - Methods getRootElementName() and setRootElementName() have been added to XMLConfiguration. For new XML documents (i.e. if the configuration was newly created and not loaded from a file) it is possible to set the name of the root element. However if the configuration was loaded from an XML document, this is not possible because I did not find a simple way to change a node's tag name using plain DOM. In this case an attempt to change the root name will throw an UnsupportedOperationException. This behavior is also explained in the javadocs. I am marking this as fixed. If somebody needs a better solution, please reopen.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jose M. Rus
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development