Michael,
thank you. That helped a lot.

On Sun Jan 09,2011 09:49 pm, Michael Glavassevich wrote:
>    Michael Ludwig <mil...@gmx.de> wrote on 01/09/2011 09:02:36 PM:
>    > Mansour Al Akeel schrieb am 09.01.2011 um 22:30 (+0200):
>    >
>    > > From what I see, it's common requirement to serialize sax events,
>    and
>    > > write them as XML to a stream.
>    > >
>    > > I don't a big problem inclusing xalan-j or xmlwriter package, but
>    > > wondering since this is a common requirement it should be available
>    > > with JDK or one of the xml parsers (like xerces). I did a search
>    but I
>    > > was not able to find one of these writers in JAXP. May be I am
>    doing
>    > > something wrong here, or missing something obvious for others, or
>    > > using these classes in a way that I am not suppose to.
>    >
>    > 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.
>    JAXP does support this. You can use a TransformerHandler [1] to write
>    SAX events to a stream:
>    ==========================
>    import javax.xml.transform.TransformerFactory;
>    import javax.xml.transform.sax.SAXTransformerFactory;
>    import javax.xml.transform.sax.TransformerHandler;
>    import javax.xml.transform.stream.StreamResult;
>    ...
>    SAXTransformerFactory tf = (SAXTransformerFactory)
>    TransformerFactory.newInstance();
>    TransformerHandler th = tf.newTransformerHandler();
>    th.setResult(new StreamResult(...));
>    th.startDocument();
>    ...
>    // fire other SAX events to the TransformerHandler.
>    ...
>    th.endDocument();
>    ==========================
>    The JAXP transform API is implemented in Xalan and JDK 1.4+.
> 
>    > --
>    > Michael Ludwig
>    >
>    > ---------------------------------------------------------------------
>    > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
>    > For additional commands, e-mail: j-users-h...@xerces.apache.org
>    Thanks.
>    [1]
>    [1]http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/transform/
>    sax/TransformerHandler.html
>    Michael Glavassevich
>    XML Parser Development
>    IBM Toronto Lab
>    E-mail: mrgla...@ca.ibm.com
>    E-mail: mrgla...@apache.org
> 
> References
> 
>    1. 
> http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/transform/sax/TransformerHandler.html

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

Reply via email to