History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-345
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Goroschenya Eugene
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

Dom4JWriter.addAttribute work incorrect

Created: 18/Sep/06 12:12 PM   Updated: 07/Oct/06 05:07 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.x Maintenance

File Attachments: 1. Java Source File Dom4JWriterTest.java (1 kb)

Issue Links:
Duplicate
 


 Description  « Hide
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.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 18/Sep/06 03:03 PM
Fixed in Subversion.

Joerg Schaible - 18/Sep/06 03:03 PM
Just forgotten: Thanks for heads-up. :)

Goroschenya Eugene - 22/Sep/06 11:28 AM
Thanks for quick fixing.