You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2002/01/07 20:03:17 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSDGroupTraverser.java
neilg 02/01/07 11:03:17
Modified: java/src/org/apache/xerces/impl/msg
XMLSchemaMessages.properties
java/src/org/apache/xerces/impl/xs SchemaGrammar.java
XSConstraints.java
java/src/org/apache/xerces/impl/xs/traversers
XSDGroupTraverser.java
Log:
implement (finally!) redefinition constraint src-redefine.6.2.2
Revision Changes Path
1.34 +1 -0 xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
Index: XMLSchemaMessages.properties
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XMLSchemaMessages.properties 3 Jan 2002 20:58:47 -0000 1.33
+++ XMLSchemaMessages.properties 7 Jan 2002 19:03:16 -0000 1.34
@@ -193,6 +193,7 @@
src-redefine.6.1.1 = src-redefine.6.1.1: if a group child of a <redefine> element contains a group ref'ing itself, it must have exactly 1; this one has ''{0}''.
src-redefine.6.1.2 = src-redefine.6.1.2: the group ''{0}'' which contains a reference to a group being redefined must have minOccurs = maxOccurs = 1.
src-redefine.6.2.1 = src-redefine.6.2.1: no group in the redefined schema with a name matching ''{0}''.
+ src-redefine.6.2.2 = src-redefine.6.2.2: group ''{0}'' does not properly restrict the group it redefines; constraint violated: ''{1}''.
src-redefine.7.1 = src-redefine.7.1: if an attributeGroup child of a <redefine> element contains an attributeGroup ref'ing itself, it must have exactly 1; this one has ''{0}''.
src-redefine.7.2.1 = src-redefine.7.2.1: no attributeGroup in the redefined schema with a name matching ''{0}''.
src-redefine.7.2.2 = src-redefine.7.2.2: attributeGroup ''{0}'' does not properly restrict the attributeGroup it redefines; constraint violated: ''{1}''.
1.7 +34 -1 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SchemaGrammar.java 6 Dec 2001 21:49:36 -0000 1.6
+++ SchemaGrammar.java 7 Jan 2002 19:03:17 -0000 1.7
@@ -79,7 +79,7 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.6 2001/12/06 21:49:36 neilg Exp $
+ * @version $Id: SchemaGrammar.java,v 1.7 2002/01/07 19:03:17 neilg Exp $
*/
public class SchemaGrammar extends Grammar {
@@ -280,6 +280,12 @@
private int fCTCount = 0;
private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE];
+ // an array to store groups being redefined by restriction
+ // even-numbered elements are the derived groups, odd-numbered ones their bases
+ private static final int REDEFINED_GROUP_INIT_SIZE = 2;
+ private int fRGCount = 0;
+ private XSGroupDecl[] fRedefinedGroupDecls = new XSGroupDecl[REDEFINED_GROUP_INIT_SIZE];
+
// a flag to indicate whether we have checked the 3 constraints on this
// grammar.
boolean fFullChecked = false;
@@ -294,6 +300,17 @@
}
/**
+ * add a group redefined by restriction: for later constraint checking
+ */
+ public final void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base) {
+ if (fRGCount == fRedefinedGroupDecls.length)
+ // double array size each time.
+ fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount << 2);
+ fRedefinedGroupDecls[fRGCount++] = derived;
+ fRedefinedGroupDecls[fRGCount++] = base;
+ }
+
+ /**
* get all complex type decls: for later constraint checking
*/
final XSComplexTypeDecl[] getUncheckedComplexTypeDecls() {
@@ -303,6 +320,16 @@
}
/**
+ * get all redefined groups: for later constraint checking
+ */
+ final XSGroupDecl[] getRedefinedGroupDecls() {
+ if (fRGCount < fRedefinedGroupDecls.length)
+ fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount);
+ return fRedefinedGroupDecls;
+ }
+
+
+ /**
* after the first-round checking, some types don't need to be checked
* against UPA again. here we trim the array to the proper size.
*/
@@ -352,6 +379,12 @@
static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
+ System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
+ return newArray;
+ }
+
+ static final XSGroupDecl[] resize(XSGroupDecl[] oldArray, int newSize) {
+ XSGroupDecl[] newArray = new XSGroupDecl[newSize];
System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
return newArray;
}
1.13 +36 -1 xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java
Index: XSConstraints.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSConstraints.java 5 Dec 2001 16:36:42 -0000 1.12
+++ XSConstraints.java 7 Jan 2002 19:03:17 -0000 1.13
@@ -73,7 +73,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSConstraints.java,v 1.12 2001/12/05 16:36:42 lmartin Exp $
+ * @version $Id: XSConstraints.java,v 1.13 2002/01/07 19:03:17 neilg Exp $
*/
public class XSConstraints {
@@ -316,6 +316,41 @@
SchemaGrammar[] grammars = grammarResolver.getGrammars();
for (int i = grammars.length-1; i >= 0; i--) {
SGHandler.addSubstitutionGroup(grammars[i].getSubstitutionGroups());
+ }
+
+ // before worrying about complexTypes, let's get
+ // groups redefined by restriction out of the way.
+ for (int g = grammars.length-1; g >= 0; g--) {
+ XSGroupDecl [] redefinedGroups = grammars[g].getRedefinedGroupDecls();
+ for(int i=0; i<redefinedGroups.length; ) {
+ XSGroupDecl derivedGrp = redefinedGroups[i++];
+ XSParticleDecl derivedParticle = derivedGrp.fParticle;
+ XSGroupDecl baseGrp = redefinedGroups[i++];
+ XSParticleDecl baseParticle = baseGrp.fParticle;
+ if(baseParticle == null) {
+ if(derivedParticle != null) { // can't be a restriction!
+ errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, "rcase-Recurse.2"},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
+ } else {
+ try {
+ particleValidRestriction(SGHandler,
+ derivedParticle, baseParticle);
+ } catch (XMLSchemaException e) {
+ String key = e.getKey();
+ errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ key,
+ e.getArgs(),
+ XMLErrorReporter.SEVERITY_ERROR);
+ errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, key},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
+ }
+ }
}
// for each complex type, check the 3 constraints.
1.2 +12 -1 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
Index: XSDGroupTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSDGroupTraverser.java 25 Oct 2001 20:36:04 -0000 1.1
+++ XSDGroupTraverser.java 7 Jan 2002 19:03:17 -0000 1.2
@@ -78,7 +78,7 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
* @author Lisa Martin, IBM
- * @version $Id: XSDGroupTraverser.java,v 1.1 2001/10/25 20:36:04 elena Exp $
+ * @version $Id: XSDGroupTraverser.java,v 1.2 2002/01/07 19:03:17 neilg Exp $
*/
class XSDGroupTraverser extends XSDAbstractParticleTraverser {
@@ -205,6 +205,17 @@
group.fTargetNamespace = schemaDoc.fTargetNamespace;
group.fParticle = particle;
grammar.addGlobalGroupDecl(group);
+ }
+ }
+ if(group != null) {
+ // store groups redefined by restriction in the grammar so
+ // that we can get at them at full-schema-checking time.
+ Object redefinedGrp = fSchemaHandler.getGrpOrAttrGrpRedefinedByRestriction(XSDHandler.GROUP_TYPE,
+ new QName(fSchemaHandler.EMPTY_STRING, strNameAttr, strNameAttr, schemaDoc.fTargetNamespace),
+ schemaDoc);
+ if(redefinedGrp != null) {
+ // store in grammar
+ grammar.addRedefinedGroupDecl(group, (XSGroupDecl)redefinedGrp);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org