Author: knoaman
Date: Thu May 28 21:19:11 2009
New Revision: 779777

URL: http://svn.apache.org/viewvc?rev=779777&view=rev
Log:
Allow for namespace growth - for now we use the same grammar instance and we do 
not override any global declarations

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.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

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=779777&r1=779776&r2=779777&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 Thu May 
28 21:19:11 2009
@@ -784,9 +784,10 @@
     }
 
     public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
-        addGlobalAttributeDecl(decl);
+        //addGlobalAttributeDecl(decl);
         if (location != null) {
             fGlobalAttrDeclsExt.put(location+","+ decl.fName, decl);
+            decl.setNamespaceItem(this);
         }
     }
 
@@ -799,9 +800,10 @@
     }
 
     public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String 
location) {
-        addGlobalAttributeGroupDecl(decl);
+        //addGlobalAttributeGroupDecl(decl);
         if (location != null) {
             fGlobalAttrGrpDeclsExt.put(location+","+decl.fName, decl);
+            decl.setNamespaceItem(this);
         }
     }
 
@@ -822,9 +824,10 @@
     }
 
     public void addGlobalElementDecl(XSElementDecl decl, String location) {
-        addGlobalElementDecl(decl);
+        //addGlobalElementDecl(decl);
         if (location != null) {
             fGlobalElemDeclsExt.put(location+","+decl.fName, decl);
+            decl.setNamespaceItem(this);
         }
     }
 
@@ -837,9 +840,10 @@
     }
 
     public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
-        addGlobalGroupDecl(decl);
+        //addGlobalGroupDecl(decl);
         if (location != null) {
             fGlobalGroupDeclsExt.put(location+","+decl.fName, decl);
+            decl.setNamespaceItem(this);
         }
     }
 
@@ -852,9 +856,10 @@
     }
 
     public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
-        addGlobalNotationDecl(decl);
+        //addGlobalNotationDecl(decl);
         if (location != null) {
             fGlobalNotationDeclsExt.put(location+","+decl.fName, decl);
+            decl.setNamespaceItem(this);
         }
     }
 
@@ -872,9 +877,15 @@
     }
 
     public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
-        addGlobalTypeDecl(decl);
+        //addGlobalTypeDecl(decl);
         if (location != null) {
             fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+            if (decl instanceof XSComplexTypeDecl) {
+                ((XSComplexTypeDecl) decl).setNamespaceItem(this);
+            }
+            else if (decl instanceof XSSimpleTypeDecl) {
+                ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+            }
         }
     }
 
@@ -887,9 +898,10 @@
     }
 
     public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String 
location) {
-        addGlobalComplexTypeDecl(decl);
+        //addGlobalComplexTypeDecl(decl);
         if (location != null) {
             fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+            decl.setNamespaceItem(this);
         }
     }
     
@@ -904,9 +916,12 @@
     }
 
     public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
-        addGlobalSimpleTypeDecl(decl);
+        //addGlobalSimpleTypeDecl(decl);
         if (location != null) {
             fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
+            if (decl instanceof XSSimpleTypeDecl) {
+                ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+            }
         }
     }
 
@@ -919,7 +934,7 @@
     }
 
     public final void addIDConstraintDecl(XSElementDecl elmDecl, 
IdentityConstraint decl, String location) {
-        addIDConstraintDecl(elmDecl, decl);
+        //addIDConstraintDecl(elmDecl, decl);
         if (location != null) {
             
fGlobalIDConstraintDeclsExt.put(location+","+decl.getIdentityConstraintName(), 
decl);
         }
@@ -934,7 +949,7 @@
 
     public final XSAttributeDecl getGlobalAttributeDecl(String declName, 
String location) {
         if (location == null) {
-            return getGlobalAttributeDecl(declName);
+            return null;//getGlobalAttributeDecl(declName);
         }
         return(XSAttributeDecl)fGlobalAttrDeclsExt.get(location+","+declName);
     }
@@ -948,7 +963,7 @@
 
     public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String 
declName, String location) {
         if (location == null) {
-            return getGlobalAttributeGroupDecl(declName);
+            return null;//getGlobalAttributeGroupDecl(declName);
         }
         
return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(location+","+declName);
     }
@@ -962,7 +977,7 @@
 
     public final XSElementDecl getGlobalElementDecl(String declName, String 
location) {
         if (location == null) {
-            return getGlobalElementDecl(declName);
+            return null;//getGlobalElementDecl(declName);
         }
         return(XSElementDecl)fGlobalElemDeclsExt.get(location+","+declName);
     }
@@ -976,7 +991,7 @@
 
     public final XSGroupDecl getGlobalGroupDecl(String declName, String 
location) {
         if (location == null) {
-            return getGlobalGroupDecl(declName);
+            return null;//getGlobalGroupDecl(declName);
         }
         return(XSGroupDecl)fGlobalGroupDeclsExt.get(location+","+declName);
     }
@@ -990,7 +1005,7 @@
 
     public final XSNotationDecl getGlobalNotationDecl(String declName, String 
location) {
         if (location == null) {
-            return getGlobalNotationDecl(declName);
+            return null;//getGlobalNotationDecl(declName);
         }
         
return(XSNotationDecl)fGlobalNotationDeclsExt.get(location+","+declName);
     }
@@ -1004,7 +1019,7 @@
 
     public final XSTypeDefinition getGlobalTypeDecl(String declName, String 
location) {
         if (location == null) {
-            return getGlobalTypeDecl(declName);
+            return null;//getGlobalTypeDecl(declName);
         }
         return(XSTypeDefinition)fGlobalTypeDeclsExt.get(location+","+declName);
     }
@@ -1018,7 +1033,7 @@
 
     public final IdentityConstraint getIDConstraintDecl(String declName, 
String location) {
         if (location == null) {
-            return getIDConstraintDecl(declName);
+            return null;//getIDConstraintDecl(declName);
         }
         
return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(location+","+declName);
     }

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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -179,9 +179,18 @@
         attrGrp.fAnnotations = annotations;
         
         // make an entry in global declarations.
-        final String loc = (fSchemaHandler.fNamespaceGrowth)
-                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-        grammar.addGlobalAttributeGroupDecl(attrGrp, loc);
+        if (!fSchemaHandler.fNamespaceGrowth) {
+            grammar.addGlobalAttributeGroupDecl(attrGrp);
+        }
+        else {
+            if (grammar.getGlobalAttributeGroupDecl(attrGrp.fName) == null) {
+                grammar.addGlobalAttributeGroupDecl(attrGrp);
+            }
+            final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+            if (grammar.getGlobalAttributeGroupDecl(attrGrp.fName, loc) == 
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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -439,9 +439,20 @@
         
         // Step 2: register attribute decl to the grammar
         if (isGlobal) {
-            final String loc = (fSchemaHandler.fNamespaceGrowth)
-                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addGlobalAttributeDecl(attribute, loc);
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addGlobalAttributeDecl(attribute);
+            }
+            else {
+                if (grammar.getGlobalAttributeDecl(nameAtt) == null) {
+                    grammar.addGlobalAttributeDecl(attribute);
+                }
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if (loc != null) {
+                    if (grammar.getGlobalAttributeDecl(nameAtt, loc) == 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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -197,9 +197,18 @@
             reportSchemaError("s4s-att-must-appear", new 
Object[]{SchemaSymbols.ELT_COMPLEXTYPE, SchemaSymbols.ATT_NAME}, 
complexTypeNode);
             type = null;
         } else {
-            final String loc = (fSchemaHandler.fNamespaceGrowth) 
-                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addGlobalComplexTypeDecl(type, loc);
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addGlobalComplexTypeDecl(type);
+            }
+            else {
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if (grammar.getGlobalTypeDecl(type.getName()) == null) {
+                    grammar.addGlobalComplexTypeDecl(type);
+                }
+                if (grammar.getGlobalTypeDecl(type.getName(), loc) == 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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -504,9 +504,18 @@
         
         // Step 5: register the element decl to the grammar
         if (isGlobal) {
-            final String loc = (fSchemaHandler.fNamespaceGrowth)
-                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addGlobalElementDecl(element, loc);
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addGlobalElementDecl(element);
+            }
+            else {
+                if (grammar.getGlobalElementDecl(element.fName) == null) {
+                    grammar.addGlobalElementDecl(element);
+                }
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if (grammar.getGlobalElementDecl(element.fName, loc) == 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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -221,9 +221,20 @@
                 annotations = XSObjectListImpl.EMPTY_LIST;
             }
             group.fAnnotations = annotations;                
-            final String loc = (fSchemaHandler.fNamespaceGrowth)
-                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addGlobalGroupDecl(group, loc);
+            // Add group declaration to grammar
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addGlobalGroupDecl(group);
+            }
+            else {
+                if (grammar.getGlobalGroupDecl(group.fName) == null) {
+                    grammar.addGlobalGroupDecl(group);
+                }
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if (grammar.getGlobalGroupDecl(group.fName, loc) == 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=779777&r1=779776&r2=779777&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 
Thu May 28 21:19:11 2009
@@ -777,18 +777,18 @@
         // we have a namespace collision
         if (nsCollision) {
             SchemaGrammar sg2 = 
fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
-            if (sg2.isImmutable()) {
-                sg = new SchemaGrammar(sg2);
-                fGrammarBucket.putGrammar(sg);
+            //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 {
+            //    updateImportListWith(sg);
+            //}
+            //else {
                 sg = sg2;
-            }
+            //}
             
             // update import list of the new grammar
-            updateImportListFor(sg);
+            //updateImportListFor(sg);
         }
         else if (referType == XSDDescription.CONTEXT_INCLUDE ||
                 referType == XSDDescription.CONTEXT_REDEFINE) {
@@ -1095,13 +1095,15 @@
             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);
+                if (importedGrammars != null) {
+                    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;
                         }
-                        break;
                     }
                 }
             }
@@ -1476,19 +1478,19 @@
         Object retObj = getGlobalDeclFromGrammar(sGrammar, declType, 
declToTraverse.localpart);
         
         // if the component is parsed, return it
-        if (!fNamespaceGrowth) {
+        //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)) {
+        else if 
(null2EmptyString(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;

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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -93,9 +93,18 @@
             } else {
                 // add key reference to element decl
                 // and stuff this in the grammar
-                final String loc = (fSchemaHandler.fNamespaceGrowth)
-                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-                grammar.addIDConstraintDecl(element, keyRef, loc);
+                if (!fSchemaHandler.fNamespaceGrowth) {
+                    grammar.addIDConstraintDecl(element, keyRef);
+                }
+                else {
+                    final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                    if 
(grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName()) == null) {
+                        grammar.addIDConstraintDecl(element, keyRef);
+                    }
+                    if 
((grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName(), loc) == 
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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -106,9 +106,18 @@
             reportSchemaError("s4s-elt-must-match.1", args, content);
             
         }
-        final String loc = (fSchemaHandler.fNamespaceGrowth)
-                ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-        grammar.addGlobalNotationDecl(notation, loc);
+        if (!fSchemaHandler.fNamespaceGrowth) {
+            grammar.addGlobalNotationDecl(notation);
+        }
+        else {
+            final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+            if (grammar.getGlobalNotationDecl(notation.fName) == null) {
+                grammar.addGlobalNotationDecl(notation);
+            }
+            if (grammar.getGlobalNotationDecl(notation.fName, loc) == 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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -115,9 +115,18 @@
         
         // don't add global components without name to the grammar
         if (type != null) {
-            final String loc = (fSchemaHandler.fNamespaceGrowth)
-                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addGlobalSimpleTypeDecl(type, loc);
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addGlobalSimpleTypeDecl(type);
+            }
+            else {
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if (grammar.getGlobalTypeDecl(type.getName()) == null) {
+                    grammar.addGlobalSimpleTypeDecl(type);
+                }
+                if (grammar.getGlobalTypeDecl(type.getName(), loc) == 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=779777&r1=779776&r2=779777&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
 Thu May 28 21:19:11 2009
@@ -72,9 +72,18 @@
         // add it to the schema, to avoid errors when processing the instance.
         if (traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, 
attrValues)) {
             // and stuff this in the grammar
-            final String loc = (fSchemaHandler.fNamespaceGrowth)
-                    ? fSchemaHandler.schemaDocument2SystemId(schemaDoc) : null;
-            grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
+            if (!fSchemaHandler.fNamespaceGrowth) {
+                grammar.addIDConstraintDecl(element, uniqueOrKey);
+            }
+            else {
+                final String loc = 
fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+                if 
(grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName()) == null) {
+                    grammar.addIDConstraintDecl(element, uniqueOrKey);
+                }
+                if 
(grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName(), loc) == 
null) {
+                    grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
+                }
+            }
         }
 
         // and fix up attributeChecker



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to