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

Re: SAXException, checked, buy why?


Re:  SAXException
* Karl Waclawek <karl@w...> [2005-01-03 11:14]:
> Alan Gutierrez wrote:
> 
> 
> >>Maybe in that case event handlers should avoid throwing
> >>exceptions at all, and rather notify an error handler.
> >
> >
> >    Agreed.
> >    
> >    Please consider my idea again.
> >
> >    Assume at the SAX content handler author, and the SAX
> >    application author are two different entities. That the SAX
> >    content handler cannot anticipate how exceptions should be
> >    handled.
> >
> >    What is the design of an API for exception handling within the
> >    content handler? Within the observer of an observer pattern?
> >
> >    I proposed on in an earlier message:
> >
> >    public interface SAXCassandra {
> >        public void error (SAXError saxError);
> >    }
> 
> What makes this different from the ErrorHandler interface
> already specified in SAX?

    public interface ErrorHandler {
        public void error(SAXParseException exception)
            throws SAXException;
        public void fatalError(SAXParseException exception)
            throws SAXException;
        public void warning(SAXParseException exception)
            throws SAXException;
    }

    It is meant to respond to errors in parse, not errors in content
    handling. If content handler authors were to adopt it for use as
    a means to intercept genral errors, they'd be going against the
    documented use.

    http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html

> >    By implementing this observer, and handing it off to a content
> >    handler, the application developer can inspect errors before they
> >    are thrown.
> >
> >    The sax filter author writes:
> >
> >    public void startElement(
> >        String ns, String ln, String qn, Attributes as
> >    ) {
> >      if (ln.equals("foo")) {
> >        FileInputStream in = null;
> >        String fileName = as.getValue("file-name");
> >        do {
> >          try {
> >            in = new FileInputStream(new File(fileName));
> >          } catch (FileNotFoundException e) {
> >            this.cassandra.error(new SAXError(e));
> >          }
> >        } while (in == null);
> >      }
> >    }
> >
> >    The above probably wouldn't give the application author enough
> >    information to recover from the error, but we can fix that by
> >    creating a special SAXError, or wrapping a Foo specific
> >    exception that includes the file name.

> All agreed, but see my question above.
> (Maybe I am still slow on the uptake because I celebrated too
> much on New Year's eve ;-) )

    No. You're asking the questions I asked myself.
    
--
Alan Gutierrez - alan@e...

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.