Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-446

XMLConfiguration removes empty attributes on update

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.7
    • Component/s: None
    • Labels:
      None

      Description

      Consider an XML configuration file config.xml containing:

      <configuration>
      <foo attr="aValue">
      </foo>
      </configuration>

      Update the configuration to set an attribute to empty:

      XMLConfiguration config = new XMLConfiguration("config.xml");
      config.setExpressionEngine(new XPathExpressionEngine());

      config.setProperty("foo/@attr", "");
      config.save();

      The file has been modified as follows:

      <configuration>
      <foo/>
      </configuration>

      The attribute shouldn't be removed as an empty attribute is different from a missing attribute.

      Method removing the attribute: XMLConfiguration$XMLBuilderVisitor.updateAttribute(Node node, Element elem, String name, char listDelimiter)

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              gdelepine Ghislain Del├ępine
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: