XStream
  1. XStream
  2. XSTR-345

Dom4JWriter.addAttribute work incorrect

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.x Maintenance
    • Component/s: None
    • Labels:
      None

      Description

      Dom4JWriter.addAttribute work incorrect, see attached test case.

      I want:

      <?xml version="1.0" encoding="UTF-8"?>
      <root>
      <A attrA="valA"/>
      <B attrB="valB"/>
      <C attrC="valC"/>
      </root>

      but with code:

      StringWriter stringWriter = new StringWriter();
      XMLWriter writer = new XMLWriter(stringWriter);
      Dom4JWriter dom4JWriter = new Dom4JWriter(writer);

      dom4JWriter.startNode("root");

      dom4JWriter.startNode("A");
      dom4JWriter.addAttribute("attrA", "valA");
      dom4JWriter.endNode();

      dom4JWriter.startNode("B");
      dom4JWriter.addAttribute("attrB", "valB");
      dom4JWriter.endNode();

      dom4JWriter.startNode("C");
      dom4JWriter.addAttribute("attrC", "valC");
      dom4JWriter.endNode();

      dom4JWriter.endNode();

      I get:

      <?xml version="1.0" encoding="UTF-8"?>
      <root>
      <A attrA="valA"/>
      <B attrA="valA" attrB="valB"/>
      <C attrA="valA" attrB="valB" attrC="valC"/>
      </root>

      I assume that "attributes.clear();" is necessary in Dom4JWriter.endNode() after "writer.write(element);" for correct working.

        Issue Links

          People

          • Assignee:
            Unassigned
            Reporter:
            Goroschenya Eugene
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: