Someone asked about this a couple years ago. Here were my responses then [1]. Basically SAX doesn't specify where in the stream errors are reported, so you can't assume any particular ordering in your code. The order you get is dependent on the implementation.
[1] http://marc.theaimsgroup.com/?l=xerces-j-user&m=106192278330342&w=2 Vinay Murthy <[EMAIL PROTECTED]> wrote on 01/06/2005 07:32:54 AM: > Hi, > > I was trying to validate a XML document against a XSD using a > javax.xml.parsers.SAXParser with its xmlReader set to > "org.apache.xerces.parsers.SAXParser". > > I did expect the parsing mechanism to proceed as follows for a typical > element of the kind > <name>Abcd</name>: > > 1) Upon encountering the start of the element (<name>), the > ContentHandler's startElement method would get called > 2) The data contained within the element (Abcd) is then validated > against the XSD for its type, etc. If an error were to be discovered > during the validation, the ErrorHandler's "error" method would get > called. > 3) And finally, the ContentHandler's endElement method would get > called upon reaching the end of an element (</name>) > > While the parser follows the behaviour described above for non-empty > tags, it chooses to behave differently for empty tags. > > For an empty tag of the kind: > > <price></price> > > the parser follows the pattern described above. > > But for an empty tag of the kind > > <discount/> > > I found that the "error" method of the ErrorHandler gets called first, > followed by the startElement method of the ContentHandler and finally > the endElement method of the ContentHandler - clearly a digression > from the expected behaviour. > > The version of xercesImpl.jar used was 2.6.2 and the jdk version was1.4.2_06. > > I would want to know if this is an expected behaviour of the parser. > > > Appreciate your help, > > Regards > Vinay > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]