[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

More on SAX Exceptions

  • From: Rob Lugt <roblugt@e...>
  • To: xml-dev@l...
  • Date: Thu, 12 Jul 2001 23:36:28 +0100

sax exceptions
Further to the recent thread about throwing exceptions from user code, I
would like to clarify exactly what a SAX Driver should do when it encounters
exceptions.

There are two places that an application may be told about an exception: on
return from the parse() function or via one of the ErrorHandler interfaces.
I'm looking for clarification about how the following situations should be
handled:-

1)  The SAX Driver encounters some kind of system exception, let's say it
gets an I/O error attempting to read the document entity.  Should this (a)
be thrown as a SAXException returned from parse() or (b) should it be
wrapped in a SAXParseException and handed over to
ErrorHandler::fatalError()?

2)  A handler method, let's assume EntityResolver::resolveEntity()
encounters an unrecoverable problem.  It traps an IOException.  It decides
to wrap this in a SAXException and throw it.  What should happen next?
Should this exception be (a) returned to the caller of parse() or (b) should
it be wrapped in a SAXParseException and reported to an ErrorHandler if one
exists?

3)  If you answered (b) to either of the above, then what do you think
should be done when ErrorHandler::warning() throws an Exception.  (a) return
it to parse() or (b) wrap the exception in a SAXParseException and call
ErrorHandler::fatalError().

4)  Finally, what about when ErrorHandler::fatalError() rethrows the
SAXParseException, as is the case with DefaultHandler?  This must obviously
be returned to parse() otherwise we'd be in a real pickle.

I believe the correct answer to all of the above is (a), throwing a
SAXException will cause the SAX Driver to terminate and return the thrown
exception to the caller of parse().  Without this behaviour how could the
application force a parse to cease prematurely?  It couldn't because the
ErrorHandler may deal with it and allow the parse to continue.

So, this brings me to my final question: should a SAX Driver ever call the
ErrorHandler with a real (i.e. unexpected) exception, or will these always
be returned to the caller of parse().

Regards
~Rob

--
Rob Lugt
ElCel Technology
http://www.elcel.com/



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.