Michael Glavassevich schrieb am 09.01.2011 um 21:49 (-0500): > Michael Ludwig <mil...@gmx.de> wrote on 01/09/2011 09:02:36 PM:
> > I think you're looking for org.xml.sax.helpers.DefaultHandler! > > That class doesn't do anything on its own. Sure you can extend it to > provide implementations of the various SAX2 handler methods, even > going so far as to write your own SAX serializer, but I think Mansour > was looking for something which provided that capability out of the > box. Thanks! I've never been using a lot, and it shows. :-) > JAXP does support this. You can use a TransformerHandler [1] to write > SAX events to a stream: > SAXTransformerFactory tf = (SAXTransformerFactory) > TransformerFactory.newInstance(); > TransformerHandler th = tf.newTransformerHandler(); > th.setResult(new StreamResult(...)); > th.startDocument(); > ... > // fire other SAX events to the TransformerHandler. > ... > th.endDocument(); 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 -- Michael Ludwig --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org