Skip to Content.
Sympa Menu

xom-interest - Re: [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: Re: [XOM-interest] Small bug in Serializer relating to indentation and preserving whitespace
  • Date: Sat, 20 Oct 2007 16:11:58 +1000

Hi,

Following up on this, here's an additional unit test that catches this
bug...

cheers,
asgeir

On 10/20/07, Asgeir Frimannsson <asgeirf AT gmail.com> wrote:
>
> 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
>



--
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