user993797
user993797

Reputation: 145

error method called before start element java sax processor

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

  1. start element

  2. validation error

  3. end element

when using short hand xml

<submitmonth/>

, the method call order seems to change. I noticed the call order to be below

  1. validation error

  2. start element

  3. 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

Answers (1)

keshlam
keshlam

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

Related Questions