Re: Reporting of well-formed content in malformed documents

"John Wilson" <[email protected]> Wed, 8 Oct 2003 08:25:27 +0100
Newsgroups gmane.text.xml.sax.devel,gmane.text.xml.xerces-j.devel
Organization The Wilson Partnership
Message-ID <002e01c38d6d$591a18a0$0000fea9@handel>
Elliotte Harold wrote:
> Consider a document such as the following:
>
> <root>
>   <child1/>
>   <child2>
> </root>
>
> Clearly it is malformed because the </child2> end-tag is missing.
> However, a streaming parser using SAX will still report
> startDocument(),  startElement(root), characters(),
> startElement(child1), endElement(child1), characters(), and
> startElement(child2) before the malformedness is detected and a
> SAXParseException is thrown.

endDocument() must be called before the SAXParseException is thrown (from
the specification of endDocument):

"The SAX parser will invoke this method only once, and it will be the last
method invoked during the parse. The parser shall not invoke this method
until it has either abandoned parsing (because of an unrecoverable error) or
reached the end of input"

If endDocument must be called then I can't see how the parser can justify
not calling the other methods. I would also expect a call of characters()
after startElement(child2).

John Wilson
The Wilson Partnership
http://www.wilson.co.uk



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
List: sax-devel, [email protected]
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel