Re: [xml-dev] SAX - endDocument() confusion again

"Karl Waclawek" <[email protected]> Fri, 27 Feb 2004 15:27:15 -0500
Newsgroups gmane.text.xml.sax.devel,gmane.text.xml.devel
Message-ID <00a901c3fd70$16ff7230$9e539696@citkwaclaww2k>
----- Original Message ----- 
From: "Jeff Rafter" <[email protected]>
To: "Karl Waclawek" <[email protected]>; <[email protected]>
Cc: <[email protected]>
Sent: Friday, February 27, 2004 2:54 PM


> > To me this would also mean that any exceptions thrown
> > should stop the parser without calling endDocument(), as
> > an exception is certainly a stronger error condition than
> > a fatalError() call-back that does not throw an exception.
> 
> I would be a little more open about it. I would say that because it "may"
> continue passing events, it is optional either way. With that being said, I
> think that guaranteeing endDocument for the purpose of cleanup is useful-- I
> just can't find it anywhere explicit.


For cleanup - especially for a chain of SAX filters, one problem is
that when parsing stops due to an exception, that the processors 
down the chain will not know if the stop was due to an error or not,
as they will know nothing about the exception.

What about this then:

- Add an error argument to endDocument, like in

  public void endDocument(SAXParseException exception)
                throws SAXException

  which can be null. 

- Require endDocument to be called even in case of a call-back
  exception, and have its argument wrap that exception.

This could even replace the fatalError call-back, unless
a parser wants to continue reporting (but what? - isn't
that contrary to the definition fatal error?).

IMO, guaranteeing the call to endDocument() without
the ability to pass information about the reason/status
severely limits the usefulness of that guarantee.

Karl





-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
List: sax-devel, [email protected]
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel