Refactoring SAX 1.0
andyclar at us.ibm.com
andyclar at us.ibm.com
Fri Apr 9 02:18:49 BST 1999
David,
David Brownell wrote:
> I'm still unclear on what you're suggesting ... suspect I'm
> not alone in it! Do you have an example, maybe?
>
> Remember that compatibility is a ground rule for everyone.
Yes, I've been thinking a lot about this recently and have
come up with an example of how the SAX 1.0 could be refactored.
First, I looked at the SAX interfaces and classes that are of
general use to all parsers. My list includes the following:
org.xml.sax.EntityResolver
org.xml.sax.ErrorHandler
org.xml.sax.InputSource
org.xml.sax.Locator
org.xml.sax.Parser
org.xml.sax.SAXException
org.xml.sax.SAXParseException
The EntityResolver, InputSource, and Locator objects can be
used without modification. Because general error handling is
useful to all parsers, I would rename SAXException to
XMLException and do the same for SAXParseException. These
name changes would affect the ErrorHandler callback methods.
I would keep the Parser interface the same except for
removing the callback registration methods (setDTDHandler
and setDocumentHandler) that are specific to a stream based
parser. To enable the stream based parsing functionality, I
would add a SAXParser interface that extends the new Parser
interface to add the callback registration methods.
(I'm not including code examples of what these new interfaces
and classes look like in order to keep this posting short. But
I could post further if there was interest.)
I realize that compatability with SAX 1.0 is very important
to retain. I would suggest keeping the org.xml.sax and
org.xml.sax.helpers packages the same -- don't change them
at all. Nothing would be moved or renamed. In this way,
users of SAX 1.0 would not have to change their code.
The refactored SAX could be moved to new packages. For
example, org.xml and org.xml.sax2. The org.xml package would
contain all of the general purpose interfaces and objects
and org.xml.sax2 would contain the specific SAX objects. The
latter would include all of the SAX2 extensions being
discussed now on the mailing list, as well.
--
Andy Clark * IBM, JTC - Silicon Valley * andyclar at us.ibm.com
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list