Michael Ludwig <mil...@gmx.de> wrote on 01/11/2011 04:40:50 AM:

...

> http://www.ibm.com/developerworks/xml/library/x-tipsxtf/index.html
>
> This old article from almost ten years ago talks says you can also
> invoke the serializer directly, and it still works:
>
> import org.apache.xml.serializer.OutputPropertiesFactory;
> import org.apache.xml.serializer.Serializer;
> import org.apache.xml.serializer.SerializerFactory;
>
> Properties op = OutputPropertiesFactory.getDefaultMethodProperties
("xml");
> Serializer srlzr = SerializerFactory.getSerializer(op);
> srlzr.setOutputStream(new FileOutputStream("sax2srlzr.xml"));
> fireEvents(srlzr.asContentHandler()); // calls startDocument() etc

FYI to folks that this may not be obvious to, this example uses Xalan's
serializer (serializer.jar), not the one native to Xerces-J
(org.apache.xml.serialize.* - note the slightly different and confusing
package name) which was deprecated years ago in favour of the Xalan one.

> --
> Michael Ludwig
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

Reply via email to