Author: mukulg Date: Tue Nov 12 05:56:55 2019 New Revision: 1869679 URL: http://svn.apache.org/viewvc?rev=1869679&view=rev Log: With xerces's xsd 1.1 implementation when running in xsd 1.0 mode, processing the following schema document that uses xsd idc constraints, results in java.lang.NullPointerException,
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="X"> <xs:complexType> <xs:sequence> <xs:element name="a" type="xs:integer" maxOccurs="unbounded"/> <xs:element name="b" type="xs:integer"/> </xs:sequence> </xs:complexType> <xs:key name="a_key"> <xs:selector xpath="a"/> <xs:field xpath="."/> </xs:key> </xs:element> <xs:element name="Y"> <xs:complexType> <xs:sequence> <xs:element name="a" type="xs:integer" maxOccurs="unbounded"/> <xs:element name="b" type="xs:integer"/> </xs:sequence> </xs:complexType> <xs:key ref="a_key"/> </xs:element> </xs:schema> This commit fixes this issue. I'm also now confident that, this fix is correct for the mentioned issue. Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java?rev=1869679&r1=1869678&r2=1869679&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java Tue Nov 12 05:56:55 2019 @@ -208,13 +208,14 @@ class XSDAbstractIDConstraintTraverser e // General Attribute Checking Object[] attrValues = fAttrChecker.checkAttributes(icElem, false, schemaDoc); QName referredIcQName = (QName)attrValues[XSAttributeChecker.ATTIDX_REF]; - - IdentityConstraint referredIc = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, referredIcQName, icElem); - // TODO: If the referredIc had a problem such as the refer attribute did not resolve to a unique/key, - // the referredIc will not have been built but it will be hidden. - // When we try to get its declaration, it will display Internal error. - // Same thing happens when a keyref has refer attribute which is its own name. But the internal error would be correct. - + IdentityConstraint referredIc = null; + if (referredIcQName != null) { + referredIc = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, referredIcQName, icElem); + // TODO: If the referredIc had a problem such as the refer attribute did not resolve to a unique/key, + // the referredIc will not have been built but it will be hidden. + // When we try to get its declaration, it will display Internal error. + // Same thing happens when a keyref has refer attribute which is its own name. But the internal error would be correct. + } if (referredIc == null) { fAttrChecker.returnAttrArray(attrValues, schemaDoc); return; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org