[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-j-user
Subject: Re: unusual behaviour while parsing/validating XML
From: Michael Glavassevich <mrglavas () ca ! ibm ! com>
Date: 2005-01-07 4:10:51
Message-ID: OF65B37E8B.D020EB30-ON85256F82.00157D7F-85256F82.00170192 () ca ! ibm ! com
[Download RAW message or body]
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 <vinay.murthy@gmail.com> 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: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic