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/14 22:36:42 UTC
svn commit: r734519 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs:
XSConstraints.java traversers/XSDGroupTraverser.java
Author: sandygao
Date: Wed Jan 14 13:36:42 2009
New Revision: 734519
URL: http://svn.apache.org/viewvc?rev=734519&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/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java?rev=734519&r1=734518&r2=734519&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java Wed Jan 14 13:36:42 2009
@@ -357,15 +357,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);
} catch (XMLSchemaException e) {
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java?rev=734519&r1=734518&r2=734519&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java Wed Jan 14 13:36:42 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