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/11/09 23:07:23 UTC

svn commit: r834253 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs: XSAttributeGroupDecl.java traversers/XSDComplexTypeTraverser.java

Author: sandygao
Date: Mon Nov  9 22:07:23 2009
New Revision: 834253

URL: http://svn.apache.org/viewvc?rev=834253&view=rev
Log:
A better error recovery approach when a complex type extension tries to define duplicate attribute uses. Instead of throwing away everything and derive from xs:anyType, just ignore the new duplicate attribute.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java?rev=834253&r1=834252&r2=834253&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java Mon Nov  9 22:07:23 2009
@@ -91,6 +91,14 @@
         return null;
     }
 
+    public void replaceAttributeUse(XSAttributeUse oldUse, XSAttributeUseImpl newUse) {
+        for (int i=0; i<fAttrUseNum; i++) {
+            if (fAttributeUses[i] == oldUse) {
+                fAttributeUses[i] = newUse;
+            }
+        }
+    }
+
     public XSAttributeUse getAttributeUse(String namespace, String name) {
         for (int i=0; i<fAttrUseNum; i++) {
             if ( (fAttributeUses[i].fAttrDecl.fTargetNamespace == namespace) &&

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=834253&r1=834252&r2=834253&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Mon Nov  9 22:07:23 2009
@@ -958,7 +958,6 @@
     
     
     // This method merges attribute uses from the base, into the derived set.
-    // The first duplicate attribute, if any, is returned.
     // LM: may want to merge with attributeGroup processing.
     private void mergeAttributes(XSAttributeGroupDecl fromAttrGrp,
             XSAttributeGroupDecl toAttrGrp,
@@ -968,7 +967,7 @@
     throws ComplexTypeRecoverableError {
         
         XSObjectList attrUseS = fromAttrGrp.getAttributeUses();
-        XSAttributeUseImpl  duplicateAttrUse =  null, oneAttrUse = null;
+        XSAttributeUseImpl oneAttrUse = null;
         int attrCount = attrUseS.getLength();
         for (int i=0; i<attrCount; i++) {
             oneAttrUse = (XSAttributeUseImpl)attrUseS.item(i);
@@ -988,6 +987,9 @@
                     reportSchemaError("ct-props-correct.4",
                             new Object[]{typeName, oneAttrUse.fAttrDecl.getName()},
                             elem);
+                    // Recover by using the attribute use from the base type,
+                    // to make the resulting schema "more valid".
+                    toAttrGrp.replaceAttributeUse(existingAttrUse, oneAttrUse);
                 }
             }
         }



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