Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Small bug in Serializer relating to indentation and preserving whitespace

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Asgeir Frimannsson" <asgeirf AT gmail.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Small bug in Serializer relating to indentation and preserving whitespace
  • Date: Sat, 20 Oct 2007 16:00:43 +1000

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



Archive powered by MHonArc 2.6.24.

Top of Page