You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Michael Maluck <mi...@cosyma.com> on 2000/10/30 14:33:06 UTC

SAX interfaces confusing

Hello,

I'm new to xerces-j, new to java and new to this list...

I started working with xerces-j and concentrated on the SAX
part. I found 3 interfaces that handle the document content:
 * org.xml.sax.DocumentHandler
 * org.xml.sax.ContentHandler
 * org.apache.xerces.framework.XMLDocumentHandler

The DocumentHandler interface is marked deprecated because
it belongs to the SAX1 specification. Now there are
ContentHandler and XMLDocumentHandler left.
The xerces sample SAXWriter2 uses the ContentHandler interface.
When do you use XMLDocumentHandler?
Why is there an interface different from that of Megginson?

Michael Maluck


Re: SAX interfaces confusing

Posted by David Halsted <ha...@tcimet.net>.
The sample files are a real goldmine if you're looking for bits of code.
They'll show you how to implement a ContentHandler and ErrorHandler (have a
look at SAX2Count.java).

----- Original Message -----
From: Elena Litani <hl...@jtcsv.com>
To: <xe...@xml.apache.org>
Sent: Monday, October 30, 2000 9:10 AM
Subject: Re: SAX interfaces confusing


> Hi, Michael,
>
> If you are working with SAXParser you might want to implement the
> following interfaces:
>
> ContentHandler: which tracks/handles events within XML Document.
>
> ErrorHandler: which receives notifications from the parser when errors
> in the XML Data are found
>
> You might consider implementing DTDHandler (defines events that occur
> while reading the DTD) and EntityResolver (resolving external entities
> specified in XML Document).
>
> You also need to register the interfaces you implement:
>
>
> XMLReader parser = new SAXParser();
> parser.setContentHandler(myContentHandler); file://myContentHandler
> implements ContentHandler
> parser.setErrorHandler(myErrorHandler);     file://myErrorHandler
implements
> ErrorHandler
> file://same for Entity and DTD handlers.
>
> I don't think you need to worry about XMLDocumentHandler interface. Bwt,
> both parsers SAXParser and DOMParser implement this interface.
>
> Elena
>
> Michael Maluck wrote:
> >
> > Hello,
> >
> > I'm new to xerces-j, new to java and new to this list...
> >
> > I started working with xerces-j and concentrated on the SAX
> > part. I found 3 interfaces that handle the document content:
> >  * org.xml.sax.DocumentHandler
> >  * org.xml.sax.ContentHandler
> >  * org.apache.xerces.framework.XMLDocumentHandler
> >
> > The DocumentHandler interface is marked deprecated because
> > it belongs to the SAX1 specification. Now there are
> > ContentHandler and XMLDocumentHandler left.
> > The xerces sample SAXWriter2 uses the ContentHandler interface.
> > When do you use XMLDocumentHandler?
> > Why is there an interface different from that of Megginson?
> >
> > Michael Maluck
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>


Re: SAX interfaces confusing

Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Michael,

If you are working with SAXParser you might want to implement the
following interfaces:

ContentHandler: which tracks/handles events within XML Document.

ErrorHandler: which receives notifications from the parser when errors
in the XML Data are found

You might consider implementing DTDHandler (defines events that occur
while reading the DTD) and EntityResolver (resolving external entities
specified in XML Document).

You also need to register the interfaces you implement:


XMLReader parser = new SAXParser();
parser.setContentHandler(myContentHandler); //myContentHandler
implements ContentHandler
parser.setErrorHandler(myErrorHandler);     //myErrorHandler implements
ErrorHandler
//same for Entity and DTD handlers.

I don't think you need to worry about XMLDocumentHandler interface. Bwt,
both parsers SAXParser and DOMParser implement this interface.

Elena

Michael Maluck wrote:
> 
> Hello,
> 
> I'm new to xerces-j, new to java and new to this list...
> 
> I started working with xerces-j and concentrated on the SAX
> part. I found 3 interfaces that handle the document content:
>  * org.xml.sax.DocumentHandler
>  * org.xml.sax.ContentHandler
>  * org.apache.xerces.framework.XMLDocumentHandler
> 
> The DocumentHandler interface is marked deprecated because
> it belongs to the SAX1 specification. Now there are
> ContentHandler and XMLDocumentHandler left.
> The xerces sample SAXWriter2 uses the ContentHandler interface.
> When do you use XMLDocumentHandler?
> Why is there an interface different from that of Megginson?
> 
> Michael Maluck
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org