Re: [Saxdotnet-devel] Requiring EndDocument
Brought to you by:
jeffrafter,
kwaclaw
From: Karl W. <ka...@wa...> - 2004-12-07 19:50:12
|
> This is actually something that is already in place and only affects > implementations, but we need to clarify when we require EndDocument to > be called. Actually, what you sate below differes from what is currently documented: The docs state: <quote> To be more specific about when EndDocument() must be called: It must always be called once StartDocument() has been called, even after a fatal error, unless IXmlReader.Parse() returned with an exception. </quote> > This is the proposal: > > (a) EndDocument is required if StartDocument is called > (b) Even when there is a FatalError > (c) In the event of an encoding error, StartDocument should have been > called so EndDocument still needs to be called. > (d) If there is an external exception (such as an IOExcpetion or a user > generated SaxExcpetion in a callback) EndDocument is still required. > (e) EndDocument should be the final event in a SAX event stream. > > Comments welcome, > I agree with a, b, c and e. About exceptions, whether user generated (call-back) or parser generated (IO, AV due to parser bug), they should be a dead stop. When the Parse() (or Resume()) method returned with an exception, EndDocument should not have been called. Nor should there have been any other call-backs after the exception. If you throw an exception, you want everything to stop, except for cleanup, which you should do right away in a finally clause, until it is handled. That is how exceptions normally work. If the parser throws the exception, only Parse()/Resume() can handle it, if a call-back throws an exception (that is not handled by the call-back itself), then who would reliably handle it? Again, only Parse()/Resume(). You do not want any other functions, that have nothing to do with exception handling or cleanup, called in between. Karl |