xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From knoa...@apache.org
Subject svn commit: r779298 - in /xerces/java/trunk/src/org/apache/xerces: dom/ impl/ impl/xs/ impl/xs/traversers/ parsers/
Date Wed, 27 May 2009 20:26:14 GMT
Author: knoaman
Date: Wed May 27 20:26:13 2009
New Revision: 779298

URL: http://svn.apache.org/viewvc?rev=779298&view=rev
Log:
Allow for namespace growth

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
    xerces/java/trunk/src/org/apache/xerces/impl/Constants.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XSGrammarBucket.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java
    xerces/java/trunk/src/org/apache/xerces/parsers/DOMParserImpl.java
    xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java
    xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java Wed May 27 20:26:13 2009
@@ -129,6 +129,10 @@
     protected static final String WARN_ON_DUPLICATE_ATTDEF =
         Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;
     
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+    
     // property identifiers
 
     /** Property identifier: entity manager. */
@@ -300,7 +304,8 @@
             DISALLOW_DOCTYPE_DECL_FEATURE,
             BALANCE_SYNTAX_TREES,
             WARN_ON_DUPLICATE_ATTDEF,
-            PARSER_SETTINGS
+            PARSER_SETTINGS,
+            NAMESPACE_GROWTH
         };
         addRecognizedFeatures(recognizedFeatures);
 
@@ -321,6 +326,7 @@
         setFeature(BALANCE_SYNTAX_TREES, false);
         setFeature(WARN_ON_DUPLICATE_ATTDEF, false);
         setFeature(PARSER_SETTINGS, true);
+        setFeature(NAMESPACE_GROWTH, false);
 
         // add default recognized properties
         final String[] recognizedProperties = {

Modified: xerces/java/trunk/src/org/apache/xerces/impl/Constants.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/Constants.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/Constants.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/Constants.java Wed May 27 20:26:13 2009
@@ -277,6 +277,9 @@
     /** Honour all schemaLocations feature ("honour-all-schemaLocations"). */
     public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations";
     
+    /** Namespace growth feature ("namespace-growth"). */
+    public static final String NAMESPACE_GROWTH_FEATURE = "namespace-growth";
+    
     /** XInclude processing feature ("xinclude"). */
     public static final String XINCLUDE_FEATURE = "xinclude";
     
@@ -514,6 +517,7 @@
             ID_IDREF_CHECKING_FEATURE,
             IDC_CHECKING_FEATURE,
             UNPARSED_ENTITY_CHECKING_FEATURE,
+            NAMESPACE_GROWTH_FEATURE,
     };
     
     /** Xerces properties. */

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java Wed May 27 20:26:13 2009
@@ -87,6 +87,16 @@
     SymbolHash fGlobalIDConstraintDecls;
     SymbolHash fGlobalTypeDecls;
 
+    // extended global decls: map from schema location + decl name to decl object
+    // key is location,name
+    SymbolHash fGlobalAttrDeclsExt;
+    SymbolHash fGlobalAttrGrpDeclsExt;
+    SymbolHash fGlobalElemDeclsExt;
+    SymbolHash fGlobalGroupDeclsExt;
+    SymbolHash fGlobalNotationDeclsExt;
+    SymbolHash fGlobalIDConstraintDeclsExt;
+    SymbolHash fGlobalTypeDeclsExt;
+
     // the XMLGrammarDescription member
     XSDDescription fGrammarDescription = null;
 
@@ -136,6 +146,15 @@
         fGlobalNotationDecls = new SymbolHash();
         fGlobalIDConstraintDecls = new SymbolHash();
 
+        // Extended tables
+        fGlobalAttrDeclsExt  = new SymbolHash();
+        fGlobalAttrGrpDeclsExt = new SymbolHash();
+        fGlobalElemDeclsExt = new SymbolHash();
+        fGlobalGroupDeclsExt = new SymbolHash();
+        fGlobalNotationDeclsExt = new SymbolHash();
+        fGlobalIDConstraintDeclsExt = new SymbolHash();
+        fGlobalTypeDeclsExt = new SymbolHash();
+
         // if we are parsing S4S, put built-in types in first
         // they might get overwritten by the types from S4S, but that's
         // considered what the application wants to do.
@@ -144,6 +163,79 @@
         else
             fGlobalTypeDecls = new SymbolHash();
     } // <init>(String, XSDDescription)
+    
+    // Clone an existing schema grammar
+    public SchemaGrammar(SchemaGrammar grammar) {
+        fTargetNamespace = grammar.fTargetNamespace;
+        fGrammarDescription = grammar.fGrammarDescription.makeClone();
+        //fGrammarDescription.fContextType |= XSDDescription.CONTEXT_COLLISION; // REVISIT
+        fSymbolTable = grammar.fSymbolTable; // REVISIT
+
+        fGlobalAttrDecls  = grammar.fGlobalAttrDecls.makeClone();
+        fGlobalAttrGrpDecls = grammar.fGlobalAttrGrpDecls.makeClone();
+        fGlobalElemDecls = grammar.fGlobalElemDecls.makeClone();
+        fGlobalGroupDecls = grammar.fGlobalGroupDecls.makeClone();
+        fGlobalNotationDecls = grammar.fGlobalNotationDecls.makeClone();
+        fGlobalIDConstraintDecls = grammar.fGlobalIDConstraintDecls.makeClone();
+        fGlobalTypeDecls = grammar.fGlobalTypeDecls.makeClone();
+    
+        // Extended tables
+        fGlobalAttrDeclsExt  = grammar.fGlobalAttrDeclsExt.makeClone();
+        fGlobalAttrGrpDeclsExt = grammar.fGlobalAttrGrpDeclsExt.makeClone();
+        fGlobalElemDeclsExt = grammar.fGlobalElemDeclsExt.makeClone();
+        fGlobalGroupDeclsExt = grammar.fGlobalGroupDeclsExt.makeClone();
+        fGlobalNotationDeclsExt = grammar.fGlobalNotationDeclsExt.makeClone();
+        fGlobalIDConstraintDeclsExt = grammar.fGlobalIDConstraintDeclsExt.makeClone();
+        fGlobalTypeDeclsExt = grammar.fGlobalTypeDeclsExt.makeClone();
+
+        // Annotations associated with the "root" schema of this targetNamespace
+        fNumAnnotations = grammar.fNumAnnotations;
+        if (fNumAnnotations > 0) {
+            fAnnotations = new XSAnnotationImpl[grammar.fAnnotations.length];
+            System.arraycopy(grammar.fAnnotations, 0, fAnnotations, 0, fNumAnnotations);
+        }
+        
+        // All substitution group information declared in this namespace
+        fSubGroupCount = grammar.fSubGroupCount;
+        if (fSubGroupCount > 0) {
+            fSubGroups = new XSElementDecl[grammar.fSubGroups.length];
+            System.arraycopy(grammar.fSubGroups, 0, fSubGroups, 0, fSubGroupCount);
+        }
+
+        // Array to store complex type decls for constraint checking
+        fCTCount = grammar.fCTCount;
+        if (fCTCount > 0) {
+            fComplexTypeDecls = new XSComplexTypeDecl[grammar.fComplexTypeDecls.length];
+            fCTLocators = new SimpleLocator[grammar.fCTLocators.length];
+            System.arraycopy(grammar.fComplexTypeDecls, 0, fComplexTypeDecls, 0, fCTCount);
+            System.arraycopy(grammar.fCTLocators, 0, fCTLocators, 0, fCTCount);
+        }
+        
+        // Groups being redefined by restriction
+        fRGCount = grammar.fRGCount;
+        if (fRGCount > 0) {
+            fRedefinedGroupDecls = new XSGroupDecl[grammar.fRedefinedGroupDecls.length];
+            fRGLocators = new SimpleLocator[grammar.fRGLocators.length];
+            System.arraycopy(grammar.fRedefinedGroupDecls, 0, fRedefinedGroupDecls, 0, fRGCount);
+            System.arraycopy(grammar.fRGLocators, 0, fRGLocators, 0, fRGCount);
+        }
+
+        // List of imported grammars
+        if (grammar.fImported != null) {
+            fImported = new Vector();
+            for (int i=0; i<grammar.fImported.size(); i++) {
+                fImported.add(grammar.fImported.elementAt(i));
+            }
+        }
+
+        // Locations
+        if (grammar.fLocations != null) {
+            for (int k=0; k<grammar.fLocations.size(); k++) {
+                addDocument(null, (String)grammar.fLocations.elementAt(k));
+            }
+        }
+
+    } // <init>(String, XSDDescription)
 
     // number of built-in XSTypes we need to create for base and full
     // datatype set
@@ -189,6 +281,15 @@
                 fGlobalGroupDecls = new SymbolHash(1);
                 fGlobalNotationDecls = new SymbolHash(1);
                 fGlobalIDConstraintDecls = new SymbolHash(1);
+                
+                // no extended global decls
+                fGlobalAttrDeclsExt  = new SymbolHash(1);
+                fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+                fGlobalElemDeclsExt = new SymbolHash(1);
+                fGlobalGroupDeclsExt = new SymbolHash(1);
+                fGlobalNotationDeclsExt = new SymbolHash(1);
+                fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+                fGlobalTypeDeclsExt = new SymbolHash(1);
         
                 // get all built-in types
                 fGlobalTypeDecls = schemaFactory.getBuiltInTypes();
@@ -223,6 +324,15 @@
                 fGlobalNotationDecls = new SymbolHash(1);
                 fGlobalIDConstraintDecls = new SymbolHash(1);
                 fGlobalTypeDecls = new SymbolHash(1);
+
+                // no extended global decls 
+                fGlobalAttrDeclsExt  = new SymbolHash(1);
+                fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+                fGlobalElemDeclsExt = new SymbolHash(1);
+                fGlobalGroupDeclsExt = new SymbolHash(1);
+                fGlobalNotationDeclsExt = new SymbolHash(1);
+                fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+                fGlobalTypeDeclsExt = new SymbolHash(1);
     
                 // 4 attributes, so initialize the size as 4*2 = 8
                 fGlobalAttrDecls  = new SymbolHash(8);
@@ -276,27 +386,51 @@
         public void addGlobalAttributeDecl(XSAttributeDecl decl) {
             // ignore
         }
+        public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
             // ignore
         }
+        public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalElementDecl(XSElementDecl decl) {
             // ignore
         }
+        public void addGlobalElementDecl(XSElementDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalGroupDecl(XSGroupDecl decl) {
             // ignore
         }
+        public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalNotationDecl(XSNotationDecl decl) {
             // ignore
         }
+        public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalTypeDecl(XSTypeDefinition decl) {
             // ignore
         }
+        public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+            // ignore
+        }
         public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
             // ignore
         }
+        public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
             // ignore
         }
+        public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+            // ignore
+        }
         public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
             // ignore
         }
@@ -352,6 +486,15 @@
             fGlobalGroupDecls = new SymbolHash(1);
             fGlobalNotationDecls = new SymbolHash(1);
             fGlobalIDConstraintDecls = new SymbolHash(1);
+
+            // no extended global decls
+            fGlobalAttrDeclsExt  = new SymbolHash(1);
+            fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+            fGlobalElemDeclsExt = new SymbolHash(6);
+            fGlobalGroupDeclsExt = new SymbolHash(1);
+            fGlobalNotationDeclsExt = new SymbolHash(1);
+            fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+            fGlobalTypeDeclsExt = new SymbolHash(1);
             
             // get all built-in types
             fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls;
@@ -480,27 +623,51 @@
         public void addGlobalAttributeDecl(XSAttributeDecl decl) {
             // ignore
         }
+        public void addGlobalAttributeDecl(XSAttributeGroupDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
             // ignore
         }
+        public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalElementDecl(XSElementDecl decl) {
             // ignore
         }
+        public void addGlobalElementDecl(XSElementDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalGroupDecl(XSGroupDecl decl) {
             // ignore
         }
+        public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalNotationDecl(XSNotationDecl decl) {
             // ignore
         }
+        public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalTypeDecl(XSTypeDefinition decl) {
             // ignore
         }
+        public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+            // ignore
+        }
         public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
             // ignore
         }
+        public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+            // ignore
+        }
         public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
             // ignore
         }
+        public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+            // ignore
+        }
         public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
             // ignore
         }
@@ -616,6 +783,13 @@
         decl.setNamespaceItem(this);
     }
 
+    public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
+        addGlobalAttributeDecl(decl);
+        if (location != null) {
+            fGlobalAttrDeclsExt.put(location+","+ decl.fName, decl);
+        }
+    }
+
     /**
      * register one global attribute group
      */
@@ -624,6 +798,13 @@
         decl.setNamespaceItem(this);
     }
 
+    public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+        addGlobalAttributeGroupDecl(decl);
+        if (location != null) {
+            fGlobalAttrGrpDeclsExt.put(location+","+decl.fName, decl);
+        }
+    }
+
     /**
      * register one global element
      */
@@ -640,6 +821,13 @@
         }
     }
 
+    public void addGlobalElementDecl(XSElementDecl decl, String location) {
+        addGlobalElementDecl(decl);
+        if (location != null) {
+            fGlobalElemDeclsExt.put(location+","+decl.fName, decl);
+        }
+    }
+
     /**
      * register one global group
      */
@@ -648,6 +836,13 @@
         decl.setNamespaceItem(this);
     }
 
+    public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+        addGlobalGroupDecl(decl);
+        if (location != null) {
+            fGlobalGroupDeclsExt.put(location+","+decl.fName, decl);
+        }
+    }
+
     /**
      * register one global notation
      */
@@ -656,6 +851,13 @@
         decl.setNamespaceItem(this);
     }
 
+    public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+        addGlobalNotationDecl(decl);
+        if (location != null) {
+            fGlobalNotationDeclsExt.put(location+","+decl.fName, decl);
+        }
+    }
+
     /**
      * register one global type
      */
@@ -668,7 +870,14 @@
             ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
         }
     }
-    
+
+    public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+        addGlobalTypeDecl(decl);
+        if (location != null) {
+            fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+        }
+    }
+
     /**
      * register one global complex type
      */
@@ -676,6 +885,13 @@
         fGlobalTypeDecls.put(decl.getName(), decl);
         decl.setNamespaceItem(this);
     }
+
+    public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+        addGlobalComplexTypeDecl(decl);
+        if (location != null) {
+            fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+        }
+    }
     
     /**
      * register one global simple type
@@ -687,6 +903,13 @@
         }
     }
 
+    public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+        addGlobalSimpleTypeDecl(decl);
+        if (location != null) {
+            fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+        }
+    }
+
     /**
      * register one identity constraint
      */
@@ -695,6 +918,13 @@
         fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl);
     }
 
+    public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) {
+        addIDConstraintDecl(elmDecl, decl);
+        if (location != null) {
+            fGlobalIDConstraintDeclsExt.put(location+","+decl.getIdentityConstraintName(), decl);
+        }
+    }
+
     /**
      * get one global attribute
      */
@@ -702,6 +932,13 @@
         return(XSAttributeDecl)fGlobalAttrDecls.get(declName);
     }
 
+    public final XSAttributeDecl getGlobalAttributeDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalAttributeDecl(declName);
+        }
+        return(XSAttributeDecl)fGlobalAttrDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one global attribute group
      */
@@ -709,6 +946,13 @@
         return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName);
     }
 
+    public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalAttributeGroupDecl(declName);
+        }
+        return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one global element
      */
@@ -716,6 +960,13 @@
         return(XSElementDecl)fGlobalElemDecls.get(declName);
     }
 
+    public final XSElementDecl getGlobalElementDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalElementDecl(declName);
+        }
+        return(XSElementDecl)fGlobalElemDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one global group
      */
@@ -723,6 +974,13 @@
         return(XSGroupDecl)fGlobalGroupDecls.get(declName);
     }
 
+    public final XSGroupDecl getGlobalGroupDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalGroupDecl(declName);
+        }
+        return(XSGroupDecl)fGlobalGroupDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one global notation
      */
@@ -730,6 +988,13 @@
         return(XSNotationDecl)fGlobalNotationDecls.get(declName);
     }
 
+    public final XSNotationDecl getGlobalNotationDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalNotationDecl(declName);
+        }
+        return(XSNotationDecl)fGlobalNotationDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one global type
      */
@@ -737,6 +1002,13 @@
         return(XSTypeDefinition)fGlobalTypeDecls.get(declName);
     }
 
+    public final XSTypeDefinition getGlobalTypeDecl(String declName, String location) {
+        if (location == null) {
+            return getGlobalTypeDecl(declName);
+        }
+        return(XSTypeDefinition)fGlobalTypeDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one identity constraint
      */
@@ -744,6 +1016,13 @@
         return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName);
     }
 
+    public final IdentityConstraint getIDConstraintDecl(String declName, String location) {
+        if (location == null) {
+            return getIDConstraintDecl(declName);
+        }
+        return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(location+","+declName);
+    }
+
     /**
      * get one identity constraint
      */

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Wed May 27 20:26:13 2009
@@ -134,6 +134,10 @@
     protected static final String PARSER_SETTINGS = 
         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;   
     
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+    
     // recognized features:
     private static final String[] RECOGNIZED_FEATURES = {
         SCHEMA_FULL_CHECKING,
@@ -144,7 +148,8 @@
         DISALLOW_DOCTYPE,
         GENERATE_SYNTHETIC_ANNOTATIONS,
         VALIDATE_ANNOTATIONS,
-        HONOUR_ALL_SCHEMALOCATIONS
+        HONOUR_ALL_SCHEMALOCATIONS,
+        NAMESPACE_GROWTH
     };
     
     // property identifiers
@@ -1141,7 +1146,8 @@
                 name.equals(ALLOW_JAVA_ENCODINGS) ||
                 name.equals(STANDARD_URI_CONFORMANT_FEATURE) ||
                 name.equals(GENERATE_SYNTHETIC_ANNOTATIONS) ||
-                name.equals(HONOUR_ALL_SCHEMALOCATIONS)) {
+                name.equals(HONOUR_ALL_SCHEMALOCATIONS) ||
+                name.equals(NAMESPACE_GROWTH)) {
                 return true;
                 
             }
@@ -1217,6 +1223,7 @@
             v.add(VALIDATE_ANNOTATIONS);
             v.add(GENERATE_SYNTHETIC_ANNOTATIONS);
             v.add(HONOUR_ALL_SCHEMALOCATIONS);
+            v.add(NAMESPACE_GROWTH);
             fRecognizedParameters = new DOMStringListImpl(v);      	
         }
         return fRecognizedParameters;

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Wed May 27 20:26:13 2009
@@ -18,6 +18,7 @@
 package org.apache.xerces.impl.xs;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
@@ -28,6 +29,7 @@
 
 import org.apache.xerces.impl.Constants;
 import org.apache.xerces.impl.RevalidationHandler;
+import org.apache.xerces.impl.XMLEntityManager;
 import org.apache.xerces.impl.XMLErrorReporter;
 import org.apache.xerces.impl.dv.DatatypeException;
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
@@ -54,6 +56,7 @@
 import org.apache.xerces.util.XMLAttributesImpl;
 import org.apache.xerces.util.XMLChar;
 import org.apache.xerces.util.XMLSymbols;
+import org.apache.xerces.util.URI.MalformedURIException;
 import org.apache.xerces.xni.Augmentations;
 import org.apache.xerces.xni.NamespaceContext;
 import org.apache.xerces.xni.QName;
@@ -75,6 +78,7 @@
 import org.apache.xerces.xs.AttributePSVI;
 import org.apache.xerces.xs.ElementPSVI;
 import org.apache.xerces.xs.ShortList;
+import org.apache.xerces.xs.StringList;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
@@ -171,6 +175,10 @@
 
     protected static final String PARSER_SETTINGS =
             Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
+    
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
 
     /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
     protected static final String IGNORE_XSI_TYPE =
@@ -256,6 +264,7 @@
             ID_IDREF_CHECKING,
             IDENTITY_CONSTRAINT_CHECKING,
             UNPARSED_ENTITY_CHECKING,
+            NAMESPACE_GROWTH,
         };
 
 
@@ -285,6 +294,7 @@
         null,
         null,
         null,
+        null,
     };
 
     /** Recognized properties. */
@@ -318,6 +328,9 @@
     static final XSAttributeDecl XSI_NONAMESPACESCHEMALOCATION = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);  
 
     //
+    private static final Hashtable EMPTY_TABLE = new Hashtable();
+
+    //
     // Data
     //
 
@@ -345,6 +358,9 @@
     protected boolean fIdConstraint = false;
     protected boolean fUseGrammarPoolOnly = false;
 
+    // Namespace growth feature
+    protected boolean fNamespaceGrowth = false;
+    
     /** Schema type: None, DTD, Schema */
     private String fSchemaType = null;
 
@@ -493,6 +509,8 @@
     /** Schema Grammar Description passed,  to give a chance to application to supply the Grammar */
     protected final XSDDescription fXSDDescription = new XSDDescription();
     protected final Hashtable fLocationPairs = new Hashtable();
+    protected final Hashtable fExpandedLocationPairs = new Hashtable();
+    protected final ArrayList fUnparsedLocations = new ArrayList();
 
 
     // handlers
@@ -1315,6 +1333,7 @@
         fIdConstraint = false;
         //reset XSDDescription
         fLocationPairs.clear();
+        fExpandedLocationPairs.clear();
 
         // cleanup id table
         fValidationState.resetIDTables();
@@ -1371,6 +1390,12 @@
         if (symbolTable != fSymbolTable) {
             fSymbolTable = symbolTable;
         }
+        
+        try {
+            fNamespaceGrowth = componentManager.getFeature(NAMESPACE_GROWTH);
+        } catch (XMLConfigurationException e) {
+            fNamespaceGrowth = false;
+        }
 
         try {
             fDynamicValidation = componentManager.getFeature(DYNAMIC_VALIDATION);
@@ -2380,6 +2405,10 @@
             grammars = fGrammarBucket.getGrammars();
             // return the final set of grammars validator ended up with
             if (fGrammarPool != null) {
+                // Set grammars as immutable
+                for (int k=0; k < grammars.length; k++) {
+                    grammars[k].setImmutable(true);
+                }
                 fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, grammars);
             }
             augs = endElementPSVI(true, grammars, augs);
@@ -2543,34 +2572,15 @@
         SchemaGrammar grammar = null;
         //get the grammar from local pool...
         grammar = fGrammarBucket.getGrammar(namespace);
+        
         if (grammar == null) {
-            fXSDDescription.reset();
-            fXSDDescription.fContextType = contextType;
             fXSDDescription.setNamespace(namespace);
-            fXSDDescription.fEnclosedElementName = enclosingElement;
-            fXSDDescription.fTriggeringComponent = triggeringComponet;
-            fXSDDescription.fAttributes = attributes;
-            if (fLocator != null) {
-                fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
-            }
-
-            String[] temp = null;
-            Object locationArray =
-                fLocationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
-            if (locationArray != null)
-                temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
-            if (temp != null && temp.length != 0) {
-                fXSDDescription.fLocationHints = new String[temp.length];
-                System.arraycopy(temp, 0, fXSDDescription.fLocationHints, 0, temp.length);
-            }
-
-            // give a chance to application to be able to retreive the grammar.
             if (fGrammarPool != null) {
                 grammar = (SchemaGrammar) fGrammarPool.retrieveGrammar(fXSDDescription);
                 if (grammar != null) {
                     // put this grammar into the bucket, along with grammars
                     // imported by it (directly or indirectly)
-                    if (!fGrammarBucket.putGrammar(grammar, true)) {
+                    if (!fGrammarBucket.putGrammar(grammar, true, fNamespaceGrowth)) {
                         // REVISIT: a conflict between new grammar(s) and grammars
                         // in the bucket. What to do? A warning? An exception?
                         fXSIErrorReporter.fErrorReporter.reportError(
@@ -2582,15 +2592,57 @@
                     }
                 }
             }
-            if (grammar == null && !fUseGrammarPoolOnly) {
+        }
+
+        if ((grammar == null && !fUseGrammarPoolOnly) || fNamespaceGrowth) {
+            fXSDDescription.reset();
+            fXSDDescription.fContextType = contextType;
+            fXSDDescription.setNamespace(namespace);
+            fXSDDescription.fEnclosedElementName = enclosingElement;
+            fXSDDescription.fTriggeringComponent = triggeringComponet;
+            fXSDDescription.fAttributes = attributes;
+            if (fLocator != null) {
+                fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
+            }
+
+            Hashtable locationPairs = fLocationPairs;
+            Object locationArray =
+                locationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
+            if (locationArray != null) {
+                String[] temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
+                if (temp.length != 0) {
+                    setLocationHints(fXSDDescription, temp, grammar);
+                }
+            }
+
+            if (grammar == null || fXSDDescription.fLocationHints != null) {
+                boolean toParseSchema = true;
+                if (grammar != null) {
+                     // use location hints instead
+                    locationPairs = EMPTY_TABLE;
+                }
+
                 // try to parse the grammar using location hints from that namespace..
                 try {
                     XMLInputSource xis =
                         XMLSchemaLoader.resolveDocument(
                             fXSDDescription,
-                            fLocationPairs,
+                            locationPairs,
                             fEntityResolver);
-                    grammar = fSchemaLoader.loadSchema(fXSDDescription, xis, fLocationPairs);
+                    if (grammar != null && fNamespaceGrowth) {
+                        try {
+                            // if we are dealing with a different schema location, then include the new schema
+                            // into the existing grammar
+                            if (grammar.getDocumentLocations().contains(XMLEntityManager.expandSystemId(xis.getSystemId(), xis.getBaseSystemId(), false))) {
+                                toParseSchema = false; 
+                            }
+                        }
+                        catch (MalformedURIException e) {
+                        }
+                    }
+                    if (toParseSchema) {
+                        grammar = fSchemaLoader.loadSchema(fXSDDescription, xis, fLocationPairs);
+                    }
                 } catch (IOException ex) {
                     final String [] locationHints = fXSDDescription.getLocationHints();
                     fXSIErrorReporter.fErrorReporter.reportError(
@@ -2606,6 +2658,44 @@
 
     } //findSchemaGrammar
 
+    private void setLocationHints(XSDDescription desc, String[] locations, SchemaGrammar grammar) {
+        int length = locations.length;
+        if (grammar == null) {
+            fXSDDescription.fLocationHints = new String[length];
+            System.arraycopy(locations, 0, fXSDDescription.fLocationHints, 0, length);
+        }
+        else {
+            setLocationHints(desc, locations, grammar.getDocumentLocations());
+        }
+    }
+    
+    private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
+        int length = locations.length;
+        String[] hints = new String[length];
+        int counter = 0;
+
+        for (int i=0; i<length; i++) {
+            try {
+                String id = XMLEntityManager.expandSystemId(locations[i], desc.getBaseSystemId(), false);
+                if (!docLocations.contains(id)) {
+                    hints[counter++] = locations[i];
+                }
+            }
+            catch (MalformedURIException e) {
+            }
+        }
+
+        if (counter > 0) {
+            if (counter == length) {
+                fXSDDescription.fLocationHints = hints;
+            }
+            else {
+                fXSDDescription.fLocationHints = new String[counter];
+                System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
+            }
+        }
+    }
+
     XSTypeDefinition getAndCheckXsiType(QName element, String xsiType, XMLAttributes attributes) {
         // This method also deals with clause 1.2.1.2 of the constraint
         // Validation Rule: Schema-Validity Assessment (Element)

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSGrammarBucket.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSGrammarBucket.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSGrammarBucket.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSGrammarBucket.java Wed May 27 20:26:13 2009
@@ -134,6 +134,77 @@
     }
 
     /**
+     * put a schema grammar and any grammars imported by it (directly or
+     * inderectly) into the registry. when a grammar with the same target
+     * namespace is already in the bucket, and different from the one being
+     * added, no grammar will be added into the bucket.
+     *
+     * @param grammar        the grammar to put in the registry
+     * @param deep           whether to add imported grammars
+     * @param ignoreConflict whether to ignore grammars that already exist in the grammar
+     *                       bucket or not - including 'grammar' parameter. 
+     * @return               whether the process succeeded
+     */
+    public boolean putGrammar(SchemaGrammar grammar, boolean deep, boolean ignoreConflict) {
+        if (!ignoreConflict) {
+            return putGrammar(grammar, deep);
+        }
+
+        // if grammar already exist in the bucket, we ignore the request
+        SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
+        if (sg == null) {
+            putGrammar(grammar);
+        }
+        
+        // not adding the imported grammars
+        if (!deep) {
+            return true;
+        }
+
+        // get all imported grammars, and make a copy of the Vector, so that
+        // we can recursively process the grammars, and add distinct ones
+        // to the same vector
+        Vector currGrammars = (Vector)grammar.getImportedGrammars();
+        if (currGrammars == null) {
+            return true;
+        }
+        
+        Vector grammars = ((Vector)currGrammars.clone());
+        SchemaGrammar sg1, sg2;
+        Vector gs;
+        // for all (recursively) imported grammars
+        for (int i = 0; i < grammars.size(); i++) {
+            // get the grammar
+            sg1 = (SchemaGrammar)grammars.elementAt(i);
+            // check whether the bucket has one with the same tns
+            sg2 = getGrammar(sg1.fTargetNamespace);
+            if (sg2 == null) {
+                // we need to add grammars imported by sg1 too
+                gs = sg1.getImportedGrammars();
+                // for all grammars imported by sg2, but not in the vector
+                // we add them to the vector
+                if(gs == null) continue;
+                for (int j = gs.size() - 1; j >= 0; j--) {
+                    sg2 = (SchemaGrammar)gs.elementAt(j);
+                    if (!grammars.contains(sg2))
+                        grammars.addElement(sg2);
+                }
+            }
+            // we found one with the same target namespace, ignore it
+            else  {
+                grammars.remove(sg1);
+            }
+        }
+
+        // now we have all imported grammars stored in the vector. add them
+        for (int i = grammars.size() - 1; i >= 0; i--) {
+            putGrammar((SchemaGrammar)grammars.elementAt(i));
+        }
+
+        return true;
+    }
+
+    /**
      * get all grammars in the registry
      *
      * @return an array of SchemaGrammars.

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java Wed May 27 20:26:13 2009
@@ -392,6 +392,25 @@
     }
 
     /**
+     * Convenience method. Returns a top-level simple or complex type
+     * definition.
+     * @param name The name of the definition.
+     * @param namespace The namespace of the definition, otherwise null.
+     * @param loc The schema location where the component was defined
+     * @return An <code>XSTypeDefinition</code> or null if such definition
+     *   does not exist.
+     */
+    public XSTypeDefinition getTypeDefinition(String name,
+                                              String namespace,
+                                              String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalTypeDecl(name, loc);
+    }
+
+    /**
      * Convenience method. Returns a top-level attribute declaration.
      * @param name The name of the declaration.
      * @param namespace The namespace of the definition, otherwise null.
@@ -408,6 +427,24 @@
     }
 
     /**
+     * Convenience method. Returns a top-level attribute declaration.
+     * @param name The name of the declaration.
+     * @param namespace The namespace of the definition, otherwise null.
+     * @param loc The schema location where the component was defined
+     * @return A top-level attribute declaration or null if such declaration
+     *   does not exist.
+     */
+    public XSAttributeDeclaration getAttributeDeclaration(String name,
+                                                   String namespace,
+                                                   String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalAttributeDecl(name, loc);
+    }
+
+    /**
      * Convenience method. Returns a top-level element declaration.
      * @param name The name of the declaration.
      * @param namespace The namespace of the definition, otherwise null.
@@ -424,6 +461,24 @@
     }
 
     /**
+     * Convenience method. Returns a top-level element declaration.
+     * @param name The name of the declaration.
+     * @param namespace The namespace of the definition, otherwise null.
+     * @param loc The schema location where the component was defined
+     * @return A top-level element declaration or null if such declaration
+     *   does not exist.
+     */
+    public XSElementDeclaration getElementDeclaration(String name,
+                                               String namespace,
+                                               String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalElementDecl(name, loc);
+    }
+
+    /**
      * Convenience method. Returns a top-level attribute group definition.
      * @param name The name of the definition.
      * @param namespace The namespace of the definition, otherwise null.
@@ -438,6 +493,24 @@
         }
         return (XSAttributeGroupDefinition)sg.fGlobalAttrGrpDecls.get(name);
     }
+    
+    /**
+     * Convenience method. Returns a top-level attribute group definition.
+     * @param name The name of the definition.
+     * @param namespace The namespace of the definition, otherwise null.
+     * @param loc The schema location where the component was defined
+     * @return A top-level attribute group definition or null if such
+     *   definition does not exist.
+     */
+    public XSAttributeGroupDefinition getAttributeGroup(String name,
+                                                        String namespace,
+                                                        String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalAttributeGroupDecl(name, loc);
+    }
 
     /**
      * Convenience method. Returns a top-level model group definition.
@@ -455,6 +528,25 @@
         }
         return (XSModelGroupDefinition)sg.fGlobalGroupDecls.get(name);
     }
+    
+    /**
+     * Convenience method. Returns a top-level model group definition.
+     *
+     * @param name      The name of the definition.
+     * @param namespace The namespace of the definition, otherwise null.
+     * @param loc The schema location where the component was defined
+     * @return A top-level model group definition definition or null if such
+     *         definition does not exist.
+     */
+    public XSModelGroupDefinition getModelGroupDefinition(String name,
+                                                          String namespace,
+                                                          String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalGroupDecl(name, loc);
+    }
 
 
     /**
@@ -469,6 +561,16 @@
         return (XSNotationDeclaration)sg.fGlobalNotationDecls.get(name);
     }
 
+    public XSNotationDeclaration getNotationDeclaration(String name,
+                                                 String namespace,
+                                                 String loc) {
+        SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+        if (sg == null) {
+            return null;
+        }
+        return sg.getGlobalNotationDecl(name, loc);
+    }
+
     /**
      *  [annotations]: a set of annotations if it exists, otherwise an empty 
      * <code>XSObjectList</code>. 

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java Wed May 27 20:26:13 2009
@@ -179,7 +179,9 @@
         attrGrp.fAnnotations = annotations;
         
         // make an entry in global declarations.
-        grammar.addGlobalAttributeGroupDecl(attrGrp);
+        final String loc = (fSchemaHandler.fNamespaceGrowth)
+                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+        grammar.addGlobalAttributeGroupDecl(attrGrp, loc);
         
         fAttrChecker.returnAttrArray(attrValues, schemaDoc);
         return attrGrp;

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java Wed May 27 20:26:13 2009
@@ -438,8 +438,11 @@
             return null;
         
         // Step 2: register attribute decl to the grammar
-        if (isGlobal)
-            grammar.addGlobalAttributeDecl(attribute);
+        if (isGlobal) {
+            final String loc = (fSchemaHandler.fNamespaceGrowth)
+                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addGlobalAttributeDecl(attribute, loc);
+        }
         
         return attribute;
     }

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=779298&r1=779297&r2=779298&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 Wed May 27 20:26:13 2009
@@ -197,7 +197,9 @@
             reportSchemaError("s4s-att-must-appear", new Object[]{SchemaSymbols.ELT_COMPLEXTYPE, SchemaSymbols.ATT_NAME}, complexTypeNode);
             type = null;
         } else {
-            grammar.addGlobalComplexTypeDecl(type);
+            final String loc = (fSchemaHandler.fNamespaceGrowth) 
+                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addGlobalComplexTypeDecl(type, loc);
         }
 
         fAttrChecker.returnAttrArray(attrValues, schemaDoc);

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java Wed May 27 20:26:13 2009
@@ -504,7 +504,9 @@
         
         // Step 5: register the element decl to the grammar
         if (isGlobal) {
-            grammar.addGlobalElementDecl(element);
+            final String loc = (fSchemaHandler.fNamespaceGrowth)
+                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addGlobalElementDecl(element, loc);
         }
         
         return element;

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=779298&r1=779297&r2=779298&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 May 27 20:26:13 2009
@@ -221,7 +221,9 @@
                 annotations = XSObjectListImpl.EMPTY_LIST;
             }
             group.fAnnotations = annotations;                
-            grammar.addGlobalGroupDecl(group);
+            final String loc = (fSchemaHandler.fNamespaceGrowth)
+                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addGlobalGroupDecl(group, loc);
         }
         else {
             // name attribute is not there, don't return this group.

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java Wed May 27 20:26:13 2009
@@ -140,6 +140,10 @@
     protected static final String HONOUR_ALL_SCHEMALOCATIONS = 
       Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
     
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+      Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+    
     /** Feature identifier: namespace prefixes. */
     private static final String NAMESPACE_PREFIXES =
         Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
@@ -324,6 +328,9 @@
     
     //handle multiple import feature
     private boolean fHonourAllSchemaLocations = false;
+    
+    //handle namespace growth feature
+    boolean fNamespaceGrowth = false;
 
     // the XMLErrorReporter
     private XMLErrorReporter fErrorReporter;
@@ -440,14 +447,28 @@
         // no namespace schema.
         if (referType != XSDDescription.CONTEXT_PREPARSE){
             // first try to find it in the bucket/pool, return if one is found
-            if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT && isExistingGrammar(desc)) {
+            if (fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT && isExistingGrammar(desc, fNamespaceGrowth)) {
                 grammar = fGrammarBucket.getGrammar(desc.getTargetNamespace());
             }
             else {
-                grammar = findGrammar(desc);
+                grammar = findGrammar(desc, fNamespaceGrowth);
             }
-            if (grammar != null)
-                return grammar;
+            if (grammar != null) {
+                if (!fNamespaceGrowth) {
+                    return grammar;
+                }
+                else {
+                    try {
+                        if (grammar.getDocumentLocations().contains(XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false))) {
+                            return grammar; 
+                        }
+                    }
+                    catch (MalformedURIException e) {
+                        //REVISIT: return the grammar?
+                    }
+                }
+            }
+
             schemaNamespace = desc.getTargetNamespace();
             // handle empty string URI as null
             if (schemaNamespace != null) {
@@ -500,10 +521,14 @@
             else {
                 schemaNamespace = null;
             }
-            grammar = findGrammar(desc);
-            if (grammar != null)
-                return grammar;
+            grammar = findGrammar(desc, fNamespaceGrowth);
             String schemaId = XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false);
+            if (grammar != null) {
+                if (!fNamespaceGrowth || grammar.getDocumentLocations().contains(schemaId)) {
+                    return grammar; 
+                }
+            }
+
             XSDKey key = new XSDKey(schemaId, referType, schemaNamespace);
             fTraversed.put(key, schemaRoot);
             if (schemaId != null) {
@@ -515,7 +540,7 @@
         // all traversers and clear all registries
         prepareForTraverse();
         
-        fRoot = constructTrees(schemaRoot, is.getSystemId(), desc);
+        fRoot = constructTrees(schemaRoot, is.getSystemId(), desc, grammar != null);
         if (fRoot == null) {
             return null;
         }
@@ -620,7 +645,7 @@
      * grammar pool. If a grammar is found in the pool, then add it (and all
      * imported ones) into the bucket.
      */
-    protected SchemaGrammar findGrammar(XSDDescription desc) {
+    protected SchemaGrammar findGrammar(XSDDescription desc, boolean ignoreConflict) {
         SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
         if (sg == null) {
             if (fGrammarPool != null) {
@@ -628,7 +653,7 @@
                 if (sg != null) {
                     // put this grammar into the bucket, along with grammars
                     // imported by it (directly or indirectly)
-                    if (!fGrammarBucket.putGrammar(sg, true)) {
+                    if (!fGrammarBucket.putGrammar(sg, true, ignoreConflict)) {
                         // REVISIT: a conflict between new grammar(s) and grammars
                         // in the bucket. What to do? A warning? An exception?
                         reportSchemaWarning("GrammarConflict", null, null);
@@ -669,7 +694,7 @@
     // depends on.
     // It also makes sure the targetNamespace of the schema it was
     // called to parse is correct.
-    protected XSDocumentInfo constructTrees(Element schemaRoot, String locationHint, XSDDescription desc) {
+    protected XSDocumentInfo constructTrees(Element schemaRoot, String locationHint, XSDDescription desc, boolean nsCollision) {
         if (schemaRoot == null) return null;
         String callerTNS = desc.getTargetNamespace();
         short referType = desc.getContextType();
@@ -749,12 +774,28 @@
         
         SchemaGrammar sg = null;
         
-        if (referType == XSDDescription.CONTEXT_INCLUDE ||
+        // we have a namespace collision
+        if (nsCollision) {
+            SchemaGrammar sg2 = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
+            if (sg2.isImmutable()) {
+                sg = new SchemaGrammar(sg2);
+                fGrammarBucket.putGrammar(sg);
+                // update all the grammars in the bucket to point to the new grammar.
+                updateImportListWith(sg);
+            }
+            else {
+                sg = sg2;
+            }
+            
+            // update import list of the new grammar
+            updateImportListFor(sg);
+        }
+        else if (referType == XSDDescription.CONTEXT_INCLUDE ||
                 referType == XSDDescription.CONTEXT_REDEFINE) {
             sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
         }
         else if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT) {
-            sg = findGrammar(desc);
+            sg = findGrammar(desc, false);
             if(sg == null) {
                 sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone(), fSymbolTable);
                 fGrammarBucket.putGrammar(sg);
@@ -782,6 +823,7 @@
             String localName = DOMUtil.getLocalName(child);
             
             short refType = -1;
+            boolean importCollision = false;
             
             if (localName.equals(SchemaSymbols.ELT_ANNOTATION))
                 continue;
@@ -828,7 +870,7 @@
                 // if this namespace has not been imported by this document,
                 //  then import if multiple imports support is enabled.
                 if(currSchemaInfo.isAllowedNS(schemaNamespace)) {
-                    if(!fHonourAllSchemaLocations)
+                    if(!fHonourAllSchemaLocations && !fNamespaceGrowth)
                         continue;
                 }
                 else  {
@@ -860,15 +902,33 @@
                 
                 // if a grammar with the same namespace and location exists (or being
                 // built), ignore this one (don't traverse it).
-                if ((!fHonourAllSchemaLocations && findGrammar(fSchemaGrammarDescription) != null) || isExistingGrammar(fSchemaGrammarDescription))
-                    continue;
+                SchemaGrammar isg = findGrammar(fSchemaGrammarDescription, fNamespaceGrowth);
+                if (isg != null) {
+                    if (fNamespaceGrowth) {
+                        try {
+                            if (isg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(schemaHint, fSchemaGrammarDescription.getBaseSystemId(), false))) {
+                                continue;
+                            }
+                            else {
+                                importCollision = true;
+                            }
+                        } 
+                        catch (MalformedURIException e) {
+                        }
+                    }
+                    else if (!fHonourAllSchemaLocations || isExistingGrammar(fSchemaGrammarDescription, false)) {
+                        continue;
+                    }
+                }
+                //if ((!fHonourAllSchemaLocations && findGrammar(fSchemaGrammarDescription) != null) || isExistingGrammar(fSchemaGrammarDescription))
+                //    continue;
+
                 // If "findGrammar" returns a grammar, then this is not the
                 // the first time we see a location for a given namespace.
                 // Don't consult the location pair hashtable in this case,
                 // otherwise the location will be ignored because it'll get
                 // resolved to the same location as the first hint.
-                newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child,
-                                              findGrammar(fSchemaGrammarDescription) == null);
+                newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child, isg == null);
             }
             else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
                     (localName.equals(SchemaSymbols.ELT_REDEFINE))) {
@@ -961,7 +1021,7 @@
                 newSchemaInfo = newSchemaRoot == null ? null : (XSDocumentInfo)fDoc2XSDocumentMap.get(newSchemaRoot);
             }
             else {
-               	newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription);
+               	newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription, importCollision);
             }
             
             if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
@@ -981,10 +1041,10 @@
         return currSchemaInfo;
     } // end constructTrees
     
-    private boolean isExistingGrammar(XSDDescription desc) {
+    private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
         SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
         if (sg == null) {
-            return findGrammar(desc) != null;
+            return findGrammar(desc, ignoreConflict) != null;
         }
         else if (sg.isImmutable()) {
             return true;
@@ -998,7 +1058,56 @@
             }
         }
     }
-    
+
+    /**
+     * Namespace growth
+     * 
+     * Go through the import list of a given grammar and for each imported
+     * grammar, check to see if the grammar bucket has a newer version.
+     * If a new instance is found, we update the import list with the
+     * newer version.
+     */
+    private void updateImportListFor(SchemaGrammar grammar) {
+        Vector importedGrammars = grammar.getImportedGrammars();
+        if (importedGrammars != null) {
+            for (int i=0; i<importedGrammars.size(); i++) {
+                SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i);
+                SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
+                if (isg1 != isg2) {
+                    importedGrammars.set(i, isg2);
+                }
+            }
+        }
+    }
+
+    /**
+     * Namespace growth
+     * 
+     * Go throuth the grammar bucket, and for each grammar in the bucket
+     * check the import list. If there exists a grammar in import list
+     * that has the same namespace as newGrammar, but a different instance,
+     * then update the import list and replace the old grammar instance with
+     * the new one
+     */
+    private void updateImportListWith(SchemaGrammar newGrammar) {
+        SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
+        for (int i = 0; i < schemaGrammars.length; ++i) {
+            SchemaGrammar sg = schemaGrammars[i];
+            if (sg != newGrammar) {
+                Vector importedGrammars = sg.getImportedGrammars();
+                for (int j=0; j<importedGrammars.size(); j++) {
+                    SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j);
+                    if (isg.getTargetNamespace().equals(newGrammar.getTargetNamespace())) {
+                        if (isg != newGrammar) {
+                            importedGrammars.set(j, newGrammar);
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
     // This method builds registries for all globally-referenceable
     // names.  A registry will be built for each symbol space defined
     // by the spec.  It is also this method's job to rename redefined
@@ -1362,41 +1471,29 @@
                 reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
             return null;
         }
-        
+
         // if there is such grammar, check whether the requested component is in the grammar
-        Object retObj = null;
-        switch (declType) {
-        case ATTRIBUTE_TYPE :
-            retObj = sGrammar.getGlobalAttributeDecl(declToTraverse.localpart);
-            break;
-        case ATTRIBUTEGROUP_TYPE :
-            retObj = sGrammar.getGlobalAttributeGroupDecl(declToTraverse.localpart);
-            break;
-        case ELEMENT_TYPE :
-            retObj = sGrammar.getGlobalElementDecl(declToTraverse.localpart);
-            break;
-        case GROUP_TYPE :
-            retObj = sGrammar.getGlobalGroupDecl(declToTraverse.localpart);
-            break;
-        case IDENTITYCONSTRAINT_TYPE :
-            retObj = sGrammar.getIDConstraintDecl(declToTraverse.localpart);
-            break;
-        case NOTATION_TYPE :
-            retObj = sGrammar.getGlobalNotationDecl(declToTraverse.localpart);
-            break;
-        case TYPEDECL_TYPE :
-            retObj = sGrammar.getGlobalTypeDecl(declToTraverse.localpart);
-            break;
-        }
+        Object retObj = getGlobalDeclFromGrammar(sGrammar, declType, declToTraverse.localpart);
         
         // if the component is parsed, return it
-        if (retObj != null)
-            return retObj;
-        
+        if (!fNamespaceGrowth) {
+            if (retObj != null) {
+                return retObj;
+            }
+        }
+        // namespace growth is allowed, use schema location to get global component
+        else if (declToTraverse.uri.equals(currSchema.fTargetNamespace)) {
+            String schemaLoc = (String) fDoc2SystemId.get(currSchema.fSchemaElement);
+            Object retObj2 = getGlobalDeclFromGrammar(sGrammar, declType, declToTraverse.localpart, schemaLoc);
+            if (retObj2 != null) {
+                return retObj2;
+            }
+        }
+
         XSDocumentInfo schemaWithDecl = null;
         Element decl = null;
         XSDocumentInfo declDoc = null;
-        
+
         // the component is not parsed, try to find a DOM element for it
         String declKey = declToTraverse.uri == null? ","+declToTraverse.localpart:
             declToTraverse.uri+","+declToTraverse.localpart;
@@ -1432,37 +1529,111 @@
         default:
             reportSchemaError("Internal-Error", new Object [] {"XSDHandler asked to locate component of type " + declType + "; it does not recognize this type!"}, elmNode);
         }
-        
+
         // no DOM element found, so the component can't be located
         if (decl == null) {
-            reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
-            return null;
+            if (retObj == null) {
+                reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
+            }
+            return retObj;
         }
-        
+
         // get the schema doc containing the component to be parsed
         // it should always return non-null value, but since null-checking
         // comes for free, let's be safe and check again
         schemaWithDecl = findXSDocumentForDecl(currSchema, decl, declDoc);
         if (schemaWithDecl == null) {
             // cannot get to this schema from the one containing the requesting decl
-            String code = declToTraverse.uri == null ? "src-resolve.4.1" : "src-resolve.4.2";
-            reportSchemaError(code, new Object[]{fDoc2SystemId.get(currSchema.fSchemaElement), declToTraverse.uri, declToTraverse.rawname}, elmNode);
-            return null;
+            if (retObj == null) {
+                String code = declToTraverse.uri == null ? "src-resolve.4.1" : "src-resolve.4.2";
+                reportSchemaError(code, new Object[]{fDoc2SystemId.get(currSchema.fSchemaElement), declToTraverse.uri, declToTraverse.rawname}, elmNode);
+            }
+            return retObj;
         }
+
         // a component is hidden, meaning either it's traversed, or being traversed.
         // but we didn't find it in the grammar, so it's the latter case, and
         // a circular reference. error!
         if (DOMUtil.isHidden(decl, fHiddenNodes)) {
-            String code = CIRCULAR_CODES[declType];
-            if (declType == TYPEDECL_TYPE) {
-                if (SchemaSymbols.ELT_COMPLEXTYPE.equals(DOMUtil.getLocalName(decl)))
-                    code = "ct-props-correct.3";
+            if (retObj == null) {
+                String code = CIRCULAR_CODES[declType];
+                if (declType == TYPEDECL_TYPE) {
+                    if (SchemaSymbols.ELT_COMPLEXTYPE.equals(DOMUtil.getLocalName(decl))) {
+                        code = "ct-props-correct.3";
+                    }
+                }
+                // decl must not be null if we're here...
+                reportSchemaError(code, new Object [] {declToTraverse.prefix+":"+declToTraverse.localpart}, elmNode);
             }
-            // decl must not be null if we're here...
-            reportSchemaError(code, new Object [] {declToTraverse.prefix+":"+declToTraverse.localpart}, elmNode);
-            return null;
+            return retObj;
         }
-        
+
+        return traverseGlobalDecl(declType, decl, schemaWithDecl, sGrammar);
+    } // getGlobalDecl(XSDocumentInfo, int, QName):  Object
+
+    protected Object getGlobalDeclFromGrammar(SchemaGrammar sGrammar, int declType, String localpart) {
+        Object retObj = null;
+
+        switch (declType) {
+        case ATTRIBUTE_TYPE :
+            retObj = sGrammar.getGlobalAttributeDecl(localpart);
+            break;
+        case ATTRIBUTEGROUP_TYPE :
+            retObj = sGrammar.getGlobalAttributeGroupDecl(localpart);
+            break;
+        case ELEMENT_TYPE :
+            retObj = sGrammar.getGlobalElementDecl(localpart);
+            break;
+        case GROUP_TYPE :
+            retObj = sGrammar.getGlobalGroupDecl(localpart);
+            break;
+        case IDENTITYCONSTRAINT_TYPE :
+            retObj = sGrammar.getIDConstraintDecl(localpart);
+            break;
+        case NOTATION_TYPE :
+            retObj = sGrammar.getGlobalNotationDecl(localpart);
+            break;
+        case TYPEDECL_TYPE :
+            retObj = sGrammar.getGlobalTypeDecl(localpart);
+            break;
+        }
+
+        return retObj;
+    }
+
+    protected Object getGlobalDeclFromGrammar(SchemaGrammar sGrammar, int declType, String localpart, String schemaLoc) {
+        Object retObj = null;
+
+        switch (declType) {
+        case ATTRIBUTE_TYPE :
+            retObj = sGrammar.getGlobalAttributeDecl(localpart, schemaLoc);
+            break;
+        case ATTRIBUTEGROUP_TYPE :
+            retObj = sGrammar.getGlobalAttributeGroupDecl(localpart, schemaLoc);
+            break;
+        case ELEMENT_TYPE :
+            retObj = sGrammar.getGlobalElementDecl(localpart, schemaLoc);
+            break;
+        case GROUP_TYPE :
+            retObj = sGrammar.getGlobalGroupDecl(localpart, schemaLoc);
+            break;
+        case IDENTITYCONSTRAINT_TYPE :
+            retObj = sGrammar.getIDConstraintDecl(localpart, schemaLoc);
+            break;
+        case NOTATION_TYPE :
+            retObj = sGrammar.getGlobalNotationDecl(localpart, schemaLoc);
+            break;
+        case TYPEDECL_TYPE :
+            retObj = sGrammar.getGlobalTypeDecl(localpart, schemaLoc);
+            break;
+        }
+
+        return retObj;
+    }
+
+    protected Object traverseGlobalDecl(int declType, Element decl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
+        Object retObj = null;
+
         DOMUtil.setHidden(decl, fHiddenNodes);
         SchemaNamespaceSupport nsSupport = null;
         // if the parent is <redefine> use the namespace delcs for it.
@@ -1471,43 +1642,49 @@
             nsSupport = (SchemaNamespaceSupport)fRedefine2NSSupport.get(parent);
         // back up the current SchemaNamespaceSupport, because we need to provide
         // a fresh one to the traverseGlobal methods.
-        schemaWithDecl.backupNSSupport(nsSupport);
-        
+        schemaDoc.backupNSSupport(nsSupport);
+
         // traverse the referenced global component
         switch (declType) {
+        case TYPEDECL_TYPE :
+            if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
+                retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+            }
+            else {
+                retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+            }
+            break;
         case ATTRIBUTE_TYPE :
-            retObj = fAttributeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+            retObj = fAttributeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+            break;            
+        case ELEMENT_TYPE :
+            retObj = fElementTraverser.traverseGlobal(decl, schemaDoc, grammar);
             break;
         case ATTRIBUTEGROUP_TYPE :
-            retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
-            break;
-        case ELEMENT_TYPE :
-            retObj = fElementTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+            retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
             break;
         case GROUP_TYPE :
-            retObj = fGroupTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+            retObj = fGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
+            break;
+        case NOTATION_TYPE :
+            retObj = fNotationTraverser.traverse(decl, schemaDoc, grammar);
             break;
         case IDENTITYCONSTRAINT_TYPE :
             // identity constraints should have been parsed already...
             // we should never get here
-            retObj = null;
-            break;
-        case NOTATION_TYPE :
-            retObj = fNotationTraverser.traverse(decl, schemaWithDecl, sGrammar);
-            break;
-        case TYPEDECL_TYPE :
-            if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE))
-                retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
-            else
-                retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+            break;            
         }
-        
+
         // restore the previous SchemaNamespaceSupport, so that the caller can get
         // proper namespace binding.
-        schemaWithDecl.restoreNSSupport();
-        
+        schemaDoc.restoreNSSupport();
+
         return retObj;
-    } // getGlobalDecl(XSDocumentInfo, int, QName):  Object
+    }
+
+    public String schemaDocument2SystemId(XSDocumentInfo schemaDoc) {
+        return (String)fDoc2SystemId.get(schemaDoc.fSchemaElement);
+    }
     
     // This method determines whether there is a group
     // (attributeGroup) which the given one has redefined by
@@ -2160,6 +2337,12 @@
         } catch (XMLConfigurationException e) {
             fHonourAllSchemaLocations = false;
         }
+        
+        try {
+            fNamespaceGrowth = componentManager.getFeature(NAMESPACE_GROWTH);
+        } catch (XMLConfigurationException e) {
+            fNamespaceGrowth = false;
+        }
 
         try {
             fSchemaParser.setFeature(

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java Wed May 27 20:26:13 2009
@@ -93,7 +93,9 @@
             } else {
                 // add key reference to element decl
                 // and stuff this in the grammar
-                grammar.addIDConstraintDecl(element, keyRef);
+                final String loc = (fSchemaHandler.fNamespaceGrowth)
+                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+                grammar.addIDConstraintDecl(element, keyRef, loc);
             }
         }
 

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java Wed May 27 20:26:13 2009
@@ -106,7 +106,9 @@
             reportSchemaError("s4s-elt-must-match.1", args, content);
             
         }
-        grammar.addGlobalNotationDecl(notation);
+        final String loc = (fSchemaHandler.fNamespaceGrowth)
+                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+        grammar.addGlobalNotationDecl(notation, loc);
         fAttrChecker.returnAttrArray(attrValues, schemaDoc);
         
         return notation;

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java Wed May 27 20:26:13 2009
@@ -115,7 +115,9 @@
         
         // don't add global components without name to the grammar
         if (type != null) {
-            grammar.addGlobalSimpleTypeDecl(type);
+            final String loc = (fSchemaHandler.fNamespaceGrowth)
+                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addGlobalSimpleTypeDecl(type, loc);
         }
         
         return type;

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java Wed May 27 20:26:13 2009
@@ -72,7 +72,9 @@
         // add it to the schema, to avoid errors when processing the instance.
         if (traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, attrValues)) {
             // and stuff this in the grammar
-            grammar.addIDConstraintDecl(element, uniqueOrKey);
+            final String loc = (fSchemaHandler.fNamespaceGrowth)
+                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
+            grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
         }
 
         // and fix up attributeChecker

Modified: xerces/java/trunk/src/org/apache/xerces/parsers/DOMParserImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/parsers/DOMParserImpl.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/parsers/DOMParserImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/parsers/DOMParserImpl.java Wed May 27 20:26:13 2009
@@ -114,6 +114,10 @@
     protected static final String HONOUR_ALL_SCHEMALOCATIONS = 
         Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
 
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
     // internal properties
     protected static final String SYMBOL_TABLE =
         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
@@ -451,6 +455,9 @@
                     if (name.equalsIgnoreCase(HONOUR_ALL_SCHEMALOCATIONS)) {
                         normalizedName = HONOUR_ALL_SCHEMALOCATIONS;
                     }
+                    else if (name.equals(NAMESPACE_GROWTH)) {
+                        normalizedName = NAMESPACE_GROWTH;
+                    }
                     else {
                         normalizedName = name.toLowerCase(Locale.ENGLISH);
                     }
@@ -586,6 +593,9 @@
                     if (name.equalsIgnoreCase(HONOUR_ALL_SCHEMALOCATIONS)) {
                         normalizedName = HONOUR_ALL_SCHEMALOCATIONS;
                     }
+                    else if (name.equals(NAMESPACE_GROWTH)) {
+                        normalizedName = NAMESPACE_GROWTH;
+                    }
                     fConfiguration.getFeature(normalizedName);
                     throw newTypeMismatchError(name);
                     
@@ -716,6 +726,9 @@
             if (name.equalsIgnoreCase(HONOUR_ALL_SCHEMALOCATIONS)) {
                 normalizedName = HONOUR_ALL_SCHEMALOCATIONS;
             }
+            else if (name.equals(NAMESPACE_GROWTH)) {
+                normalizedName = NAMESPACE_GROWTH;
+            }
             else {
                 normalizedName = name.toLowerCase(Locale.ENGLISH);
             }
@@ -778,6 +791,9 @@
                 if (name.equalsIgnoreCase(HONOUR_ALL_SCHEMALOCATIONS)) {
                     normalizedName = HONOUR_ALL_SCHEMALOCATIONS;
                 }
+                else if (name.equalsIgnoreCase(NAMESPACE_GROWTH)) {
+                    normalizedName = NAMESPACE_GROWTH;
+                } 
                 else {
                     normalizedName = name.toLowerCase(Locale.ENGLISH);
                 }

Modified: xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java Wed May 27 20:26:13 2009
@@ -104,6 +104,10 @@
     protected static final String HONOUR_ALL_SCHEMALOCATIONS = 
         Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
 
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
     /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
     protected static final String IGNORE_XSI_TYPE =
         Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;
@@ -210,6 +214,7 @@
             GENERATE_SYNTHETIC_ANNOTATIONS,
             VALIDATE_ANNOTATIONS,
             HONOUR_ALL_SCHEMALOCATIONS,
+            NAMESPACE_GROWTH,
             // NOTE: These shouldn't really be here but since the XML Schema
             //       validator is constructed dynamically, its recognized
             //       features might not have been set and it would cause a
@@ -230,6 +235,7 @@
         setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false);
         setFeature(VALIDATE_ANNOTATIONS, false);
         setFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
+        setFeature(NAMESPACE_GROWTH, false);
         
         setFeature(IGNORE_XSI_TYPE, false);
         setFeature(ID_IDREF_CHECKING, true);

Modified: xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java?rev=779298&r1=779297&r2=779298&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java Wed May 27 20:26:13 2009
@@ -145,6 +145,10 @@
     /** Feature identifier: honour all schemaLocations */
     protected static final String HONOUR_ALL_SCHEMALOCATIONS = 
         Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
+
+    /** Feature identifier: namespace growth */
+    protected static final String NAMESPACE_GROWTH = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
     
     /** Feature identifier: use grammar pool only */
     protected static final String USE_GRAMMAR_POOL_ONLY =
@@ -479,7 +483,7 @@
 		        NAMESPACES,
 		        NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
 		        GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
-		        HONOUR_ALL_SCHEMALOCATIONS, IGNORE_XSI_TYPE,
+		        HONOUR_ALL_SCHEMALOCATIONS, NAMESPACE_GROWTH, IGNORE_XSI_TYPE,
 		        ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING,
 		        UNPARSED_ENTITY_CHECKING, USE_GRAMMAR_POOL_ONLY,
 		        // NOTE: These shouldn't really be here but since the XML Schema
@@ -506,6 +510,7 @@
         fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
         fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
         fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
+        fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE);
         fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE);
         fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
         fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);



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


Mime
View raw message