xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Seipler" <gesei...@fht-esslingen.de>
Subject Formatting XML and XSL output ?
Date Mon, 10 Jan 2000 10:24:27 GMT
Dear apache experts,

I've just recently switched from using ProjectX from SUN and XSL:P from
Keith Visco to Xerces and Xalan. Everything is working fine so far, however
I have one problem:

How do I get an indented (pretty-printed) output ?

The code I use so far looks like:

// combine XML document and XSL stylesheet, output resulting HTML
XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new
org.apache.xalan.xpath.xdom.XercesLiaison());

 XSLTInputSource xmlSource = new XSLTInputSource((Node)xmlDoc);
XSLTInputSource xslSource = new
XSLTInputSource((Node)getXslSheet(documentURI));
Document htmlDoc = new DocumentImpl();
XSLTResultTarget xslt = new XSLTResultTarget(htmlDoc);
processor.process(xmlSource, xslSource, xslt);

 FormatterToHTML fth = new FormatterToHTML(out);
TreeWalker tw = new TreeWalker(fth);
tw.traverse(htmlDoc);

with out being a PrintWriter (of the servlet) and getXslSheet a method to
fetch the sheet from a cache.

It works. But the output is unreadable (everything in one line, or close).
Once more: how do I get an indented, readable output of an existing DOM ?
(preferably without writing my own printer for this)

Anybody able to help ?

Thanks.
And Greetings,
Georg Seipler
(geseit01@fht-esslingen.de)



Mime
View raw message