|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] SAX: Exceptions in Java SAX Implementation
ISSUE: LANGUAGE-SPECIFIC EXCEPTION HANDLING I think that it would be a bad idea for SAX to require the target language to support exceptions; as a result, I don't plan to require any of the SAX interfaces to throw specific exceptions under specific circumstances (though exceptions like java.io.IOException or java.net.MalFormedURLException may be thrown by code outside of SAX). I may, however, create an exception specifically for use with the error() implementation in the base class, for languages that support exceptions. More generally, SAX users for the Java version will almost certainly want to be able to pass their own exceptions (such as database access exceptions) through from their event handlers to the code that started the parser, and that means that exceptions will have to flow through the event handlers and the SAX parser more-or-less transparently. Does it make sense, then, simply to allow every method in the SAX/Java interfaces to throw java.lang.Exception? package org.xml.sax.DocumentHandler { public void startDocument () throws java.lang.Exception; public void endDocument () throws java.lang.Exception; /* etc. */ } The parser itself could intercept any exceptions that it knows about specifically, and simply pass through the rest to the caller. An invocation of a SAX parser in Java, then, would probably look something like this: try { parser.parse(null, "file://localhost/home/david/foo.xml"); } catch (IOException e) { /* do something */ } catch (MyException e) { /* do something else */ } catch (Exception e) { /* do yet another thing */ } We are simply passing through exceptions for languages that support them: languages without exceptions can simply omit this facility without damaging the functionality of SAX. Thanks to James Clark for raising this point a week or two ago. I would appreciate in particular hearing from Java and other OO design specialists on the merits (or otherwise) of this approach. Thanks, and all the best, David -- David Megginson ak117@f... Microstar Software Ltd. dmeggins@m... http://home.sprynet.com/sprynet/dmeggins/ xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@i... the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||






