[XOM-interest] Small bug in Serializer relating to indentation and preserving whitespace
Asgeir Frimannsson
asgeirf at gmail.com
Sat Oct 20 02:00:43 EDT 2007
Hi,
I'm experimenting with writing a streaming serializer for my XOM-based data
model, and noticed what seem to be a small bug in nu.xom.Serializer.
The following snipplet reproduces the bug:
Serializer serializer = new Serializer(System.out);
serializer.setIndent(4);
Element root = new Element("root");
Document doc = new Document(root);
Attribute spaceAtt = new Attribute(
"xml:space","http://www.w3.org/XML/1998/namespace","preserve");
root.addAttribute(spaceAtt);
root.appendChild(new Element("child1"));
// these 4 space characters should be preserved:
root.appendChild(new Text(" "));
root.appendChild(new Element("child2"));
serializer.write(doc);
Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<root xml:space="preserve"><child1/> <child2/></root>
Actual output:
<?xml version="1.0" encoding="UTF-8"?>
<root xml:space="preserve"><child1/><child2/></root>
I have attached a simple proposed patch for this bug...
cheers,
asgeir
--
Asgeir Frimannsson
PhD Candidate
School of Software Engineering and Data Communications
Queensland University of Technology
126 Margaret Street, Level 3
Brisbane QLD 4001, Australia
Phone: (+61) 7 3138 9332 Mob: (+61) 405 412 696
Email: asgeirf at gmail.com
More information about the XOM-interest
mailing list