Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.6.2
-
None
-
java 1.4.2 on intel linux running latest CVS version
Description
I created a schema that had <choice minOccurs="unbounded" maxOccurs="0"> by accident. Xerces reported an error for this as one would expect. The choice in question also had an <element ref="foo"/> in it, where "foo" was not a valid reference to an element declaration. This error was also reported correctly. Unfortunately, Xerces then NPEd inside XSDHandler with the stack trace included below.
After a little investigation, it turns out that the problem is that the choice is being interpreted as having minOccurs="0" after the error, and is thus an empty particle (Creating an empty particle explicitly also causes the bug). After processing the choice, XSDHandler then tries to remove the particle from its structures as redundant; but at this point it NPEs, presumably because it failed to create the model group for the choice correctly due to the error contained therein. Note that this only occurs for errors in the model group that aren't caught at the schema validation level. Somewhat obscure, I grant you
I will include a testcase to reproduce.
Stack trace of the error:
java.lang.NullPointerException
at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseLocalElements(XSDHandler.java:1656)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:413)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:520)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:487)
at org.apache.xerces.parsers.XMLGrammarPreparser.preparseGrammar(XMLGrammarPreparser.java:202)
at Test.main(Test.java:23)