You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2009/09/28 19:29:57 UTC
svn commit: r819653 - in /xerces/java/trunk/src/org/apache/xerces: impl/xs/
impl/xs/traversers/ util/
Author: knoaman
Date: Mon Sep 28 17:29:56 2009
New Revision: 819653
URL: http://svn.apache.org/viewvc?rev=819653&view=rev
Log:
Fix for defect 611261
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.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/util/SymbolHash.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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -98,6 +98,11 @@
SymbolHash fGlobalNotationDeclsExt;
SymbolHash fGlobalIDConstraintDeclsExt;
SymbolHash fGlobalTypeDeclsExt;
+
+ // A global map of all global element declarations - used for substitution group computation
+ // (handy when sharing components by reference, since we might end up with duplicate components
+ // that are not added to either of the global element declarations above)
+ SymbolHash fAllGlobalElemDecls;
// the XMLGrammarDescription member
XSDDescription fGrammarDescription = null;
@@ -156,6 +161,9 @@
fGlobalNotationDeclsExt = new SymbolHash();
fGlobalIDConstraintDeclsExt = new SymbolHash();
fGlobalTypeDeclsExt = new SymbolHash();
+
+ // All global elements table
+ fAllGlobalElemDecls = 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
@@ -189,6 +197,9 @@
fGlobalNotationDeclsExt = grammar.fGlobalNotationDeclsExt.makeClone();
fGlobalIDConstraintDeclsExt = grammar.fGlobalIDConstraintDeclsExt.makeClone();
fGlobalTypeDeclsExt = grammar.fGlobalTypeDeclsExt.makeClone();
+
+ // All global elements table
+ fAllGlobalElemDecls = grammar.fAllGlobalElemDecls.makeClone();
// Annotations associated with the "root" schema of this targetNamespace
fNumAnnotations = grammar.fNumAnnotations;
@@ -292,6 +303,9 @@
fGlobalNotationDeclsExt = new SymbolHash(1);
fGlobalIDConstraintDeclsExt = new SymbolHash(1);
fGlobalTypeDeclsExt = new SymbolHash(1);
+
+ // all global element decls table
+ fAllGlobalElemDecls = new SymbolHash(1);
// get all built-in types
fGlobalTypeDecls = schemaFactory.getBuiltInTypes();
@@ -335,6 +349,9 @@
fGlobalNotationDeclsExt = new SymbolHash(1);
fGlobalIDConstraintDeclsExt = new SymbolHash(1);
fGlobalTypeDeclsExt = new SymbolHash(1);
+
+ // no all global element decls
+ fAllGlobalElemDecls = new SymbolHash(1);
// 4 attributes, so initialize the size as 4*2 = 8
fGlobalAttrDecls = new SymbolHash(8);
@@ -403,6 +420,9 @@
public void addGlobalElementDecl(XSElementDecl decl, String location) {
// ignore
}
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ // ignore
+ }
public void addGlobalGroupDecl(XSGroupDecl decl) {
// ignore
}
@@ -498,6 +518,9 @@
fGlobalIDConstraintDeclsExt = new SymbolHash(1);
fGlobalTypeDeclsExt = new SymbolHash(1);
+ // all global element declarations
+ fAllGlobalElemDecls = new SymbolHash(6);
+
// get all built-in types
fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls;
@@ -511,6 +534,14 @@
fGlobalElemDecls.put(documentationDecl.fName, documentationDecl);
fGlobalElemDecls.put(appinfoDecl.fName, appinfoDecl);
+ fGlobalElemDeclsExt.put(","+annotationDecl.fName, annotationDecl);
+ fGlobalElemDeclsExt.put(","+documentationDecl.fName, documentationDecl);
+ fGlobalElemDeclsExt.put(","+appinfoDecl.fName, appinfoDecl);
+
+ fAllGlobalElemDecls.put(annotationDecl, annotationDecl);
+ fAllGlobalElemDecls.put(documentationDecl, documentationDecl);
+ fAllGlobalElemDecls.put(appinfoDecl, appinfoDecl);
+
// create complex type declarations for <annotation>, <documentation> and <appinfo>
XSComplexTypeDecl annotationType = new XSComplexTypeDecl();
XSComplexTypeDecl documentationType = new XSComplexTypeDecl();
@@ -640,6 +671,9 @@
public void addGlobalElementDecl(XSElementDecl decl, String location) {
// ignore
}
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ // ignore
+ }
public void addGlobalGroupDecl(XSGroupDecl decl) {
// ignore
}
@@ -786,11 +820,9 @@
}
public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
- if (location != null) {
- fGlobalAttrDeclsExt.put(location+","+ decl.fName, decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalAttrDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -803,36 +835,37 @@
}
public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
- if (location != null) {
- fGlobalAttrGrpDeclsExt.put(location+","+decl.fName, decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalAttrGrpDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
/**
* register one global element
*/
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ if (fAllGlobalElemDecls.get(decl) == null) {
+ fAllGlobalElemDecls.put(decl, decl);
+ // if there is a substitution group affiliation, store in an array,
+ // for further constraint checking: UPA, PD, EDC
+ if (decl.fSubGroup != null) {
+ if (fSubGroupCount == fSubGroups.length)
+ fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
+ fSubGroups[fSubGroupCount++] = decl;
+ }
+ }
+ }
+
public void addGlobalElementDecl(XSElementDecl decl) {
fGlobalElemDecls.put(decl.fName, decl);
decl.setNamespaceItem(this);
-
- // if there is a substitution group affiliation, store in an array,
- // for further constraint checking: UPA, PD, EDC
- if (decl.fSubGroup != null) {
- if (fSubGroupCount == fSubGroups.length)
- fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
- fSubGroups[fSubGroupCount++] = decl;
- }
}
public void addGlobalElementDecl(XSElementDecl decl, String location) {
- if (location != null) {
- fGlobalElemDeclsExt.put(location+","+decl.fName, decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalElemDeclsExt.put(((location != null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -845,11 +878,9 @@
}
public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
- if (location != null) {
- fGlobalGroupDeclsExt.put(location+","+decl.fName, decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalGroupDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -862,11 +893,9 @@
}
public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
- if (location != null) {
- fGlobalNotationDeclsExt.put(location+","+decl.fName, decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalNotationDeclsExt.put(((location!=null) ? location : "") + "," +decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -884,15 +913,13 @@
}
public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
- if (location != null) {
- fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
- if (decl.getNamespaceItem() == null) {
- if (decl instanceof XSComplexTypeDecl) {
- ((XSComplexTypeDecl) decl).setNamespaceItem(this);
- }
- else if (decl instanceof XSSimpleTypeDecl) {
- ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
- }
+ fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null) {
+ if (decl instanceof XSComplexTypeDecl) {
+ ((XSComplexTypeDecl) decl).setNamespaceItem(this);
+ }
+ else if (decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
}
}
}
@@ -906,11 +933,9 @@
}
public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
- if (location != null) {
- fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
- if (decl.getNamespaceItem() == null) {
- decl.setNamespaceItem(this);
- }
+ fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -925,11 +950,9 @@
}
public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
- if (location != null) {
- fGlobalTypeDeclsExt.put(location+","+decl.getName(), decl);
- if (decl.getNamespaceItem() == null && decl instanceof XSSimpleTypeDecl) {
- ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
- }
+ fGlobalTypeDeclsExt.put(((location != null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null && decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
}
}
@@ -942,9 +965,7 @@
}
public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) {
- if (location != null) {
- fGlobalIDConstraintDeclsExt.put(location+","+decl.getIdentityConstraintName(), decl);
- }
+ fGlobalIDConstraintDeclsExt.put(((location != null) ? location : "") + "," + decl.getIdentityConstraintName(), decl);
}
/**
@@ -955,10 +976,7 @@
}
public final XSAttributeDecl getGlobalAttributeDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalAttributeDecl(declName);
- }
- return(XSAttributeDecl)fGlobalAttrDeclsExt.get(location+","+declName);
+ return(XSAttributeDecl)fGlobalAttrDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
@@ -969,10 +987,7 @@
}
public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalAttributeGroupDecl(declName);
- }
- return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(location+","+declName);
+ return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
@@ -983,12 +998,9 @@
}
public final XSElementDecl getGlobalElementDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalElementDecl(declName);
- }
- return(XSElementDecl)fGlobalElemDeclsExt.get(location+","+declName);
+ return(XSElementDecl)fGlobalElemDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
-
+
/**
* get one global group
*/
@@ -997,10 +1009,7 @@
}
public final XSGroupDecl getGlobalGroupDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalGroupDecl(declName);
- }
- return(XSGroupDecl)fGlobalGroupDeclsExt.get(location+","+declName);
+ return(XSGroupDecl)fGlobalGroupDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
@@ -1011,10 +1020,7 @@
}
public final XSNotationDecl getGlobalNotationDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalNotationDecl(declName);
- }
- return(XSNotationDecl)fGlobalNotationDeclsExt.get(location+","+declName);
+ return(XSNotationDecl)fGlobalNotationDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
@@ -1025,10 +1031,7 @@
}
public final XSTypeDefinition getGlobalTypeDecl(String declName, String location) {
- if (location == null) {
- return null;//getGlobalTypeDecl(declName);
- }
- return(XSTypeDefinition)fGlobalTypeDeclsExt.get(location+","+declName);
+ return(XSTypeDefinition)fGlobalTypeDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
@@ -1039,10 +1042,7 @@
}
public final IdentityConstraint getIDConstraintDecl(String declName, String location) {
- if (location == null) {
- return null;//getIDConstraintDecl(declName);
- }
- return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(location+","+declName);
+ return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(((location != null) ? location : "") + "," + declName);
}
/**
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -42,6 +42,7 @@
import org.apache.xerces.xs.XSNamespaceItem;
import org.apache.xerces.xs.XSNamespaceItemList;
import org.apache.xerces.xs.XSNotationDeclaration;
+import org.apache.xerces.xs.XSObject;
import org.apache.xerces.xs.XSObjectList;
import org.apache.xerces.xs.XSTypeDefinition;
@@ -193,7 +194,7 @@
fSubGroupMap = buildSubGroups();
}
- private SymbolHash buildSubGroups() {
+ private SymbolHash buildSubGroups_Org() {
SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
for (int i = 0 ; i < fGrammarCount; i++) {
sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
@@ -213,6 +214,50 @@
return subGroupMap;
}
+ private SymbolHash buildSubGroups() {
+ SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
+ for (int i = 0 ; i < fGrammarCount; i++) {
+ sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
+ }
+
+ final XSObjectListImpl elements = getGlobalElements();
+ final int len = elements.getLength();
+ final SymbolHash subGroupMap = new SymbolHash(len*2);
+ XSElementDecl head;
+ XSElementDeclaration[] subGroup;
+ for (int i = 0; i < len; i++) {
+ head = (XSElementDecl)elements.item(i);
+ subGroup = sgHandler.getSubstitutionGroup(head);
+ subGroupMap.put(head, subGroup.length > 0 ?
+ new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
+ }
+ return subGroupMap;
+ }
+
+ private XSObjectListImpl getGlobalElements() {
+ final SymbolHash[] tables = new SymbolHash[fGrammarCount];
+ int length = 0;
+
+ for (int i = 0; i < fGrammarCount; i++) {
+ tables[i] = fGrammarList[i].fAllGlobalElemDecls;
+ length += tables[i].getLength();
+ }
+
+ if (length == 0) {
+ return XSObjectListImpl.EMPTY_LIST;
+ }
+
+ final XSObject[] components = new XSObject[length];
+
+ int start = 0;
+ for (int i = 0; i < fGrammarCount; i++) {
+ tables[i].getValues(components, start);
+ start += tables[i].getLength();
+ }
+
+ return new XSObjectListImpl(components, length);
+ }
+
/**
* Convenience method. Returns a list of all namespaces that belong to
* this schema.
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -182,13 +182,17 @@
if (grammar.getGlobalAttributeGroupDecl(attrGrp.fName) == null) {
grammar.addGlobalAttributeGroupDecl(attrGrp);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSAttributeGroupDecl attrGrp2 = grammar.getGlobalAttributeGroupDecl(attrGrp.fName, loc);
+ if (attrGrp2 == null) {
+ grammar.addGlobalAttributeGroupDecl(attrGrp, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSAttributeGroupDecl attrGrp2 = grammar.getGlobalAttributeGroupDecl(attrGrp.fName, loc);
- if (attrGrp2 == null) {
- grammar.addGlobalAttributeGroupDecl(attrGrp, loc);
- }
- else {
+ if (attrGrp2 != null) {
attrGrp = attrGrp2;
}
fSchemaHandler.addGlobalAttributeGroupDecl(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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -442,13 +442,16 @@
if (grammar.getGlobalAttributeDecl(nameAtt) == null) {
grammar.addGlobalAttributeDecl(attribute);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSAttributeDecl attribute2 = grammar.getGlobalAttributeDecl(nameAtt, loc);
+ if (attribute2 == null) {
+ grammar.addGlobalAttributeDecl(attribute, loc);
+ }
+
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSAttributeDecl attribute2 = grammar.getGlobalAttributeDecl(nameAtt, loc);
- if (attribute2 == null) {
- grammar.addGlobalAttributeDecl(attribute, loc);
- }
- else {
+ if (attribute2 != null) {
attribute = attribute2;
}
fSchemaHandler.addGlobalAttributeDecl(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=819653&r1=819652&r2=819653&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Mon Sep 28 17:29:56 2009
@@ -198,13 +198,17 @@
if (grammar.getGlobalTypeDecl(type.getName()) == null) {
grammar.addGlobalComplexTypeDecl(type);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
+ if (type2 == null) {
+ grammar.addGlobalComplexTypeDecl(type, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
- if (type2 == null) {
- grammar.addGlobalComplexTypeDecl(type, loc);
- }
- else {
+ if (type2 != null) {
if (type2 instanceof XSComplexTypeDecl) {
type = (XSComplexTypeDecl) type2;
}
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -504,16 +504,23 @@
// Step 5: register the element decl to the grammar
if (isGlobal) {
+ grammar.addGlobalElementDeclAll(element);
+
if (grammar.getGlobalElementDecl(element.fName) == null) {
grammar.addGlobalElementDecl(element);
}
+
+ // we also add the element to the tolerate duplicates list as well
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSElementDecl element2 = grammar.getGlobalElementDecl(element.fName, loc);
+ if (element2 == null) {
+ grammar.addGlobalElementDecl(element, loc);
+ }
+
+ // if we are tolerating duplicates, and we found a duplicate declaration
+ // use the duplicate one instead
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSElementDecl element2 = grammar.getGlobalElementDecl(element.fName, loc);
- if (element2 == null) {
- grammar.addGlobalElementDecl(element, loc);
- }
- else {
+ if (element2 != null) {
element = element2;
}
fSchemaHandler.addGlobalElementDecl(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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -225,13 +225,17 @@
if (grammar.getGlobalGroupDecl(group.fName) == null) {
grammar.addGlobalGroupDecl(group);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSGroupDecl group2 = grammar.getGlobalGroupDecl(group.fName, loc);
+ if (group2 == null) {
+ grammar.addGlobalGroupDecl(group, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSGroupDecl group2 = grammar.getGlobalGroupDecl(group.fName, loc);
- if (group2 == null) {
- grammar.addGlobalGroupDecl(group, loc);
- }
- else {
+ if (group2 != null) {
group = group2;
}
fSchemaHandler.addGlobalGroupDecl(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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -3138,34 +3138,66 @@
switch (componentType) {
case XSConstants.TYPE_DEFINITION :
- if (sg.getGlobalTypeDecl(name) == null) {
- sg.addGlobalTypeDecl((XSTypeDefinition) component);
+ if (!((XSTypeDefinition) component).getAnonymous()) {
+ if (sg.getGlobalTypeDecl(name) == null) {
+ sg.addGlobalTypeDecl((XSTypeDefinition) component);
+ }
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalTypeDecl(name, "") == null) {
+ sg.addGlobalTypeDecl((XSTypeDefinition) component, "");
+ }
}
break;
case XSConstants.ATTRIBUTE_DECLARATION :
- if (sg.getGlobalAttributeDecl(name) == null) {
- sg.addGlobalAttributeDecl((XSAttributeDecl) component);
+ if (((XSAttributeDecl) component).getScope() == XSAttributeDecl.SCOPE_GLOBAL) {
+ if (sg.getGlobalAttributeDecl(name) == null) {
+ sg.addGlobalAttributeDecl((XSAttributeDecl) component);
+ }
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalAttributeDecl(name, "") == null) {
+ sg.addGlobalAttributeDecl((XSAttributeDecl) component, "");
+ }
}
break;
case XSConstants.ATTRIBUTE_GROUP :
if (sg.getGlobalAttributeDecl(name) == null) {
sg.addGlobalAttributeGroupDecl((XSAttributeGroupDecl) component);
}
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalAttributeDecl(name, "") == null) {
+ sg.addGlobalAttributeGroupDecl((XSAttributeGroupDecl) component, "");
+ }
break;
case XSConstants.ELEMENT_DECLARATION :
- if (sg.getGlobalElementDecl(name) == null) {
- sg.addGlobalElementDecl((XSElementDecl) component);
+ if (((XSElementDecl) component).getScope() == XSElementDecl.SCOPE_GLOBAL) {
+ sg.addGlobalElementDeclAll((XSElementDecl) component);
+
+ if (sg.getGlobalElementDecl(name) == null) {
+ sg.addGlobalElementDecl((XSElementDecl) component);
+ }
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalElementDecl(name, "") == null) {
+ sg.addGlobalElementDecl((XSElementDecl) component, "");
+ }
}
break;
case XSConstants.MODEL_GROUP_DEFINITION :
if (sg.getGlobalGroupDecl(name) == null) {
sg.addGlobalGroupDecl((XSGroupDecl) component);
}
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalGroupDecl(name, "") == null) {
+ sg.addGlobalGroupDecl((XSGroupDecl) component, "");
+ }
break;
case XSConstants.NOTATION_DECLARATION :
if (sg.getGlobalNotationDecl(name) == null) {
sg.addGlobalNotationDecl((XSNotationDecl) component);
}
+ // store the declaration in the extended map, using an empty location
+ if (sg.getGlobalNotationDecl(name, "") == null) {
+ sg.addGlobalNotationDecl((XSNotationDecl) component, "");
+ }
break;
case XSConstants.IDENTITY_CONSTRAINT :
case XSConstants.ATTRIBUTE_USE :
@@ -3173,7 +3205,7 @@
break;
}
}
-
+
private void updateImportDependencies(Hashtable table) {
Enumeration keys = table.keys();
String namespace;
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -96,13 +96,17 @@
if (grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName()) == null) {
grammar.addIDConstraintDecl(element, keyRef);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final IdentityConstraint idc = grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName(), loc);
+ if (idc == null) {
+ grammar.addIDConstraintDecl(element, keyRef, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final IdentityConstraint idc = grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName(), loc);
- if (idc == null) {
- grammar.addIDConstraintDecl(element, keyRef, loc);
- }
- else {
+ if (idc != null) {
if (idc instanceof KeyRef) {
keyRef = (KeyRef) idc;
}
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -109,13 +109,17 @@
if (grammar.getGlobalNotationDecl(notation.fName) == null) {
grammar.addGlobalNotationDecl(notation);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSNotationDecl notation2 = grammar.getGlobalNotationDecl(notation.fName, loc);
+ if (notation2 == null) {
+ grammar.addGlobalNotationDecl(notation, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final XSNotationDecl notation2 = grammar.getGlobalNotationDecl(notation.fName, loc);
- if (notation2 == null) {
- grammar.addGlobalNotationDecl(notation, loc);
- }
- else {
+ if (notation2 != null) {
notation = notation2;
}
fSchemaHandler.addGlobalNotationDecl(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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -112,13 +112,17 @@
if (grammar.getGlobalTypeDecl(type.getName()) == null) {
grammar.addGlobalSimpleTypeDecl(type);
}
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
+ if (type2 == null) {
+ grammar.addGlobalSimpleTypeDecl(type, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
- if (type2 == null) {
- grammar.addGlobalSimpleTypeDecl(type, loc);
- }
- else {
+ if (type2 != null) {
if (type2 instanceof XSSimpleType) {
type = (XSSimpleType) type2;
}
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=819653&r1=819652&r2=819653&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 Mon Sep 28 17:29:56 2009
@@ -75,13 +75,16 @@
if (grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName()) == null) {
grammar.addIDConstraintDecl(element, uniqueOrKey);
}
+
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final IdentityConstraint idc = grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName(), loc);
+ if (idc == null) {
+ grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
+ }
+
+ // handle duplicates
if (fSchemaHandler.fTolerateDuplicates) {
- final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
- final IdentityConstraint idc = grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName(), loc);
- if (idc == null) {
- grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
- }
- else {
+ if (idc != null) {
if (idc instanceof UniqueOrKey) {
uniqueOrKey = (UniqueOrKey) uniqueOrKey;
}
Modified: xerces/java/trunk/src/org/apache/xerces/util/SymbolHash.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/util/SymbolHash.java?rev=819653&r1=819652&r2=819653&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/util/SymbolHash.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/util/SymbolHash.java Mon Sep 28 17:29:56 2009
@@ -138,7 +138,7 @@
* Return key/value pairs of all entries in the map
*/
public Object[] getEntries() {
- Object[] entries = new String[fNum << 1];
+ Object[] entries = new Object[fNum << 1];
for (int i=0, j=0; i<fTableSize && j<fNum << 1; i++) {
for (Entry entry = fBuckets[i]; entry != null; entry = entry.next) {
entries[j] = entry.key;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org