On 8/28/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: jmsnell
Date: Mon Aug 28 09:27:16 2006
New Revision: 437742
URL: http://svn.apache.org/viewvc?rev=437742&view=rev
Log:
Pretty Printing! NamedWriter that will output the XML with line breaks and
indents
Example use:
Abdera abdera = new Abdera();
Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();
entry.setId(FOMHelper.generateUuid());
entry.setUpdated(new java.util.Date());
entry.addAuthor("James");
entry.setContent("<a><b><c><d>foo</d></c></b></a>", Content.Type.XML);
Writer pw = (Writer)abdera.getWriterFactory().getWriter("PrettyXML");
pw.writeTo(entry,System.out);
The output produced looks like;
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<id>urn:uuid:...</id>
<updated>...</updated>
<author>
<name>James</name>
</author>
<content type="application/xml">
<a>
<b>
<c>
<d>foo</d>
</c>
</b>
</a>
</content>
</entry>
The width of the indent is currently hard coded at 2 spaces. We could make that
configurable.
Nice! Looks very similar to the half finished version I've got
sitting in my working copy ;-)
-garrett