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 was 1.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]

Reply via email to