You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2009/01/29 19:39:26 UTC

svn commit: r738954 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: XSConstraints.java traversers/XSDGroupTraverser.java

Author: sandygao
Date: Thu Jan 29 18:39:26 2009
New Revision: 738954

URL: http://svn.apache.org/viewvc?rev=738954&view=rev
Log:
Fixing an NPE in complex type restriction involving <redefine>.

If a redefining schema document has the following group redefinition in <redefine>:

  <xsd:group name="gp">
    <xsd:annotation/>
  </xsd:group>

We will store "null" as the value of the model group in the global model group definition.
When this group is checked against the one being redefined, we try to make use of this "null"
field and get NPE.

The fix is to change the derivation checking code to check whether the field is null. If it's
null, then treat it as empty.

A TODO is also added asking whether it's better to not store "null" in the above error situation,
and store, say, an empty sequence instead.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java?rev=738954&r1=738953&r2=738954&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java Thu Jan 29 18:39:26 2009
@@ -375,15 +375,21 @@
                 XSModelGroupImpl derivedMG = derivedGrp.fModelGroup;
                 XSGroupDecl baseGrp = redefinedGroups[i++];
                 XSModelGroupImpl baseMG = baseGrp.fModelGroup;
+                fakeDerived.fValue = derivedMG;
+                fakeBase.fValue = baseMG;
                 if(baseMG == null) {
                     if(derivedMG != null) { // can't be a restriction!
                         reportSchemaError(errorReporter, rgLocators[i/2-1],
                                 "src-redefine.6.2.2",
                                 new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
                     }
+                } else if (derivedMG == null) {
+                    if (!fakeBase.emptiable()) {
+                        reportSchemaError(errorReporter, rgLocators[i/2-1],
+                                "src-redefine.6.2.2",
+                                new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
+                    }
                 } else {
-                    fakeDerived.fValue = derivedMG;
-                    fakeBase.fValue = baseMG;
                     try {
                         particleValidRestriction(fakeDerived, SGHandler, fakeBase, SGHandler, schemaVersion);
                     } catch (XMLSchemaException e) {

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java?rev=738954&r1=738953&r2=738954&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java Thu Jan 29 18:39:26 2009
@@ -209,6 +209,8 @@
             if (strNameAttr != null) {
                 group.fName = strNameAttr;
                 group.fTargetNamespace = schemaDoc.fTargetNamespace;
+                // TODO: if particle == null (error situation?), should we
+                //       recover by synthesizing an empty sequence?
                 if (particle != null)
                     group.fModelGroup = (XSModelGroupImpl)particle.fValue;
                 XSObjectList annotations;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org