logo       

Re: pretty printing page output: msg#00116

java.enhydra.xmlc

Subject: Re: pretty printing page output

At 11:15 PM 9/17/2003 -0700, you wrote:
The DOMFormatter does not suffer from this problem so I'm using it for now. Only thing is that I've made use of OutputOptions and I still see no change in the source output.

try{
response.setContentType("text/html");
OutputOptions output = new OutputOptions();
output.setPrettyPrinting(true);
output.setFormat(OutputOptions.FORMAT_HTML);
output.setIndentSize(2);
DOMFormatter df = new DOMFormatter();
df.setOutputOptions(output);
ServletOutputStream sos = response.getOutputStream();
df.write(page, sos);
}catch(IOException izzy){
izzy.printStackTrace();
}

Anything else I need to do to get it formatted?

As a stopgap measure, try doing this...

//write the doc to a byte stream
byte[] bytes = dfm.toBytes(node);

//filter the byte stream to tidy
Tidy tidy = new Tidy();
tidy.setIndentContent(true);
tidy.setSpaces(2);
tidy.setQuiet(true);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tidy.parse(bais, baos);

//now write the file
writer.write(baos.toString());


Jake

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise