jfs <[EMAIL PROTECTED]> wrote on 11/16/2008 02:29:21 PM:

> Sorry, originally I was passing format to the XMLSerializer:
>
> XMLSerializer serial = new XMLSerializer(new
> BufferedWriter(res.getWriter()), format);
>
> However the serialized output is on a single line. I also tried the
> following code, avoiding use of XMLSerializer:

There is a parameter called "format-pretty-print" [1] which you're not
setting.

> [...]
>    System.setProperty(DOMImplementationRegistry.PROPERTY,
> "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");

This is Sun's implementation, not Xerces'. They forked the codebase a long
time ago and have made many modifications to it that we would not know
about here.

>    DOMImplementationRegistry registry =
> DOMImplementationRegistry.newInstance();
>    DOMImplementationLS impl = (DOMImplementationLS)
> registry.getDOMImplementation("LS");
>    LSOutput out = impl.createLSOutput();
>    out.setByteStream(res.getOutputStream());
>    LSSerializer writer = impl.createLSSerializer();
>    writer.write(xhtmlDoc, out);
>
>    DOMImplementation implementation =
> DOMImplementationRegistry.newInstance().getDOMImplementation("XML 3.0");
>    DOMImplementationLS feature = (DOMImplementationLS)
> implementation.getFeature("LS", "3.0");
>    LSSerializer serializer = feature.createLSSerializer();
>    LSOutput output = feature.createLSOutput();
>    output.setByteStream(res.getOutputStream());
>    serializer.write(xhtmlDoc, output);
> [...]
>
> (Leaving away "System.setProperty(...)" would cause getDOMImplementation
> return NULL.)

Probably a bug in the JDK and also a good indication that you don't
actually have Xerces' jars on your classpath.

> Output is still on a single line. I guess that this is caused by how I am
> writing the serialized output to the servlet's response, rather then how
the
> serialization is configured. Do you have any ideas?

Couldn't even guess what is happening here since you're not using the
Apache implementation. In Xerces 2.9.0 we reimplemented the DOM Level 3
serialization support on top of the Apache Xalan serializer
(serializer.jar) and then deprecated the old XMLSerializer. Given when
Sun's Java 5 and 6 were released I doubt either has anything based on the
current implementation in it.

> Thanks for your help!
> -Felix

Thanks.

[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#parameter-format-pretty-print

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Reply via email to