Altova Mailing List Archives


Re: [xml-dev] SAXException, checked, buy why?

From: Alan Gutierrez <alan-xml-dev@-----.--->
To: Karl Waclawek <karl@--------.--->
Date: 1/3/2005 4:30:00 PM
* 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...

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.