abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Rooney" <roo...@electricjellyfish.net>
Subject Re: svn commit: r437742 - in /incubator/abdera/java/trunk: build/ parser/src/main/java/org/apache/abdera/parser/stax/util/ parser/src/main/resources/ parser/src/main/resources/META-INF/ parser/src/main/resources/META-INF/services/
Date Mon, 28 Aug 2006 16:36:15 GMT
On 8/28/06, jmsnell@apache.org <jmsnell@apache.org> 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

Mime
View raw message