Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] XML pretty printer

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Luca Passani <passani AT eunet.no>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] XML pretty printer
  • Date: Mon, 23 Jul 2007 10:46:49 +0200


Hi, I have built myself an utility to manage a rather large XML file. What the utility does is to load the file, manipulate the OM and, finally, spit out XML again the usual way.

public static void toPrettyXML(Document doc, OutputStream out) throws Exception {
Serializer serializer = new Serializer(out);
serializer.setIndent(2);
serializer.setMaxLength(200);
serializer.setPreserveBaseURI(false);
serializer.write(doc);
serializer.flush();
out.close();
}

it all looked very good, until users of my project came back and told me that what looked like this before (observe empty line between the two elements):

<device>
:
</device>

<device>
:
</device>

Now looks like this:

<device>
:
</device>
<device>
:
</device>


which impacts readibility (it's a 5Meg file, but still assumed to be readable to humans!).

Is there a way to fix this with the XOM serializer/pretty printer? of course, I only want th extra line to apply to the "device" element and not to others.

Thanks

Luca








Archive powered by MHonArc 2.6.24.

Top of Page