Reputation: 145
I am parsing an xml document using java sax parser and validating it against a schema. When validating for empty elements, the parser works fine if the the element is of the following format
<submitmonth></submitmonth>
The error i receive is good ( Says that submit month be null and should be such and such ). The order in which the code executes is
start element
validation error
end element
when using short hand xml
<submitmonth/>
, the method call order seems to change. I noticed the call order to be below
validation error
start element
end element
Not sure why this is happening. I would expect the short hand to be handled the same way as regular xml
Help please
Upvotes: 0
Views: 132
Reputation: 8058
There is no guarantee in SAX about when errors are reported versus when start and end element are reported. Your program should probably be written to tolerate that variation.
If you think a parser should be more regular about that behavior, take it up with that parser's authors or try another SAX parser.
There really isn't anything we can do here beyond offering those two suggestions.
Upvotes: 1