You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Kyle F. Downey" <kd...@amberarcher.com> on 2001/01/05 21:19:19 UTC
error reporting for XML schemas
Hello,
When there's an error reported in TraverseSchema to do with the XML schema
definition itself being incorrect, this does not stop processing. As a
result, later on in the validator it will fail with a
NullPointerException.
For example, if you define a type
<complexType name="providerType">
<attribute name="debug" type="boolean" use="optional"/>
<all>
<element ref="protocol"/>
<element ref="host"/>
</all>
</complexType>
TraverseSchema fails on its assertion that it have seen some kind of
"particle" (an element, an all, etc.) before it processes an attribute:
traversing complex Type : providerType,,.
child element name debug
org.xml.sax.SAXParseException: Schema error: complexType 'providerType'
with a elementOnly or mixed content need to have at least one particle
child.
at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1065)
at
org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError(TraverseSchema.java:4628)
at
org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchemaError(TraverseSchema.java:4615)
at
org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTypeDecl(TraverseSchema.java:1953)
It then continues despite having a bad type definition and throws a
NullPointerException in XMLValidator:
java.lang.NullPointerException
at
org.apache.xerces.validators.schema.SchemaGrammar.getElementComplexTypeInfo(SchemaGrammar.java:248)
at
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:2566)
at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:835)
By the time that bubbled up to JDOM, I had almost no information about the
cause. I kept on recompiling, turning on debugging and stack trace
printing features until I happened to notice that error further up and
corrected it (placing my attribute tag after the all). Shouldn't
TraverseSchema halt processing immediately if it can't define a type?
regards,
kd