Re: pretty printing page output

Jacob Kjome <[email protected]> Wed, 17 Sep 2003 23:50:24 -0500
Newsgroups gmane.comp.java.enhydra.xmlc
Message-ID <[email protected]>
At 02:21 PM 9/15/2003 -0700, you wrote:
>Is there a way to format the resulting HTML from the toDocument() call 
>into a more easily readable form?  Looks like there's not a single newline 
>in the entire output.  That's great for a production system, but it's a 
>bit hard on the eyes trying to debug HTML issues.


You shouldn't be using toDocument() anyway.  It doesn't provide an 
opportunity to add formatting options.  Are you using XMLC in a servlet 
environment?  Then use....

XMLCContext#writeDOM(HttpServletRequest, HttpServletResponse, 
OutputOptions, XMLObject)

The OutputOptions provide the magic.  Use OutputOptions#setPrettyPrinting(true)

Check out the XMLC-2.2 or 2.2.1 release in the tomcat example for code 
using XMLCContext.

Alternatively, you can just create a new DOMFormatter, pass it 
OutputOptions (with pretty printing as described above), and then use one 
of the various DOMFormatter#write() methods.

Make sure to check out the Javadoc for XMLC (comes in a zip file within the 
2.2 and 2.2.1 releases) as it will show you all the options I've mentioned 
above.


Jake