Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Small ugly regression in Serializer

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Small ugly regression in Serializer
  • Date: Wed, 24 Sep 2003 15:57:18 -0700

Hi,

I believe there is a small cosmetic regression in Serializer using pretty printing indentation between 1.0d20 and 1.0d21:

Result with xom-1.0d21:
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<itemSet>
<item1/>
<item2/></itemSet>
[empty line]


Result with xom-1.0d20:
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<itemSet>
<item1/>
<item2/>
</itemSet>

The result with 1.0d20 seems more appropriate.
Here is the code to reproduce:


package gov.lbl.dsd.firefish.trash;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;

public class PrettyXMLTest {

public static void main(String[] args) throws Exception {
Element items = new Element("itemSet");
items.appendChild(new Element("item1"));
items.appendChild(new Element("item2"));

System.out.println(toPrettyXML(new Document(items)));
}

public static void toPrettyXML(Document doc, OutputStream out) throws Exception {
Serializer serializer = new Serializer(out);
serializer.setIndent(4);
serializer.setMaxLength(80);
serializer.preserveBaseURI(true);
serializer.write(doc);
serializer.flush();
out.close();
}

public static String toPrettyXML(Document doc) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
toPrettyXML(doc, out);
return out.toString();
}

}





Archive powered by MHonArc 2.6.24.

Top of Page