You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/11/21 21:06:53 UTC
svn commit: r477862 [2/2] -
/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java?view=diff&rev=477862&r1=477861&r2=477862
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSConstraints.java Tue Nov 21 12:06:52 2006
@@ -35,13 +35,8 @@
import java.util.Vector;
/**
- * Constaints shared by traversers and validator
+ * Constraints shared by traversers and validator
*
- * IHR: Visited on 2006-11-17
- * I've added a boolean return value to particleValidRestriction (it was a void function)
- * to help the checkRecurseLax to know when expansion has happened and no order is required
- * (IHR@xbrl.org) (Ignacio@Hernandez-Ros.com)
- *
* @xerces.internal
*
* @author Sandy Gao, IBM
@@ -50,6 +45,11 @@
*/
public class XSConstraints {
+ // IHR: Visited on 2006-11-17
+ // Added a boolean return value to particleValidRestriction (it was a void function)
+ // to help the checkRecurseLax to know when expansion has happened and no order is required
+ // (IHR@xbrl.org) (Ignacio@Hernandez-Ros.com)
+
static final int OCCURRENCE_UNKNOWN = SchemaSymbols.OCCURRENCE_UNBOUNDED-1;
static final XSSimpleType STRING_TYPE = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
@@ -114,8 +114,9 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)derived,
- (XSSimpleType)base, block);
- } else {
+ (XSSimpleType)base, block);
+ }
+ else {
return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
}
}
@@ -142,7 +143,7 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)derived,
- (XSSimpleType)base, block);
+ (XSSimpleType)base, block);
}
/**
@@ -169,7 +170,7 @@
// 2 All of the following must be true:
// 2.1 restriction is not in the subset, or in the {final} of its own {base type definition};
if ((block & XSConstants.DERIVATION_RESTRICTION) != 0 ||
- (derived.getBaseType().getFinal() & XSConstants.DERIVATION_RESTRICTION) != 0) {
+ (derived.getBaseType().getFinal() & XSConstants.DERIVATION_RESTRICTION) != 0) {
return false;
}
@@ -181,14 +182,14 @@
// 2.2.2 D's base type definition is not the simple ur-type definition and is validly derived from B given the subset, as defined by this constraint.
if (directBase != SchemaGrammar.fAnySimpleType &&
- checkSimpleDerivation(directBase, base, block)) {
+ checkSimpleDerivation(directBase, base, block)) {
return true;
}
// 2.2.3 D's {variety} is list or union and B is the simple ur-type definition.
if ((derived.getVariety() == XSSimpleType.VARIETY_LIST ||
- derived.getVariety() == XSSimpleType.VARIETY_UNION) &&
- base == SchemaGrammar.fAnySimpleType) {
+ derived.getVariety() == XSSimpleType.VARIETY_UNION) &&
+ base == SchemaGrammar.fAnySimpleType) {
return true;
}
@@ -229,7 +230,7 @@
// 2.3 All of the following must be true:
// 2.3.1 D's {base type definition} must not be the ur-type definition.
if (directBase == SchemaGrammar.fAnyType ||
- directBase == SchemaGrammar.fAnySimpleType) {
+ directBase == SchemaGrammar.fAnySimpleType) {
return false;
}
@@ -250,7 +251,7 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)directBase,
- (XSSimpleType)base, block);
+ (XSSimpleType)base, block);
}
return false;
@@ -313,15 +314,15 @@
}
static void reportSchemaError(XMLErrorReporter errorReporter,
- SimpleLocator loc,
- String key, Object[] args) {
+ SimpleLocator loc,
+ String key, Object[] args) {
if (loc != null) {
errorReporter.reportError(loc, XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, XMLErrorReporter.SEVERITY_ERROR);
+ key, args, XMLErrorReporter.SEVERITY_ERROR);
}
else {
errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, XMLErrorReporter.SEVERITY_ERROR);
+ key, args, XMLErrorReporter.SEVERITY_ERROR);
}
}
@@ -332,9 +333,9 @@
* Element Declrations Consistent.
*/
public static void fullSchemaChecking(XSGrammarBucket grammarBucket,
- SubstitutionGroupHandler SGHandler,
- CMBuilder cmBuilder,
- XMLErrorReporter errorReporter) {
+ SubstitutionGroupHandler SGHandler,
+ CMBuilder cmBuilder,
+ XMLErrorReporter errorReporter) {
// get all grammars, and put all substitution group information
// in the substitution group handler
SchemaGrammar[] grammars = grammarBucket.getGrammars();
@@ -359,8 +360,8 @@
if(baseMG == null) {
if(derivedMG != null) { // can't be a restriction!
reportSchemaError(errorReporter, rgLocators[i/2-1],
- "src-redefine.6.2.2",
- new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
}
} else {
fakeDerived.fValue = derivedMG;
@@ -370,11 +371,11 @@
} catch (XMLSchemaException e) {
String key = e.getKey();
reportSchemaError(errorReporter, rgLocators[i/2-1],
- key,
- e.getArgs());
+ key,
+ e.getArgs());
reportSchemaError(errorReporter, rgLocators[i/2-1],
- "src-redefine.6.2.2",
- new Object[]{derivedGrp.fName, key});
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, key});
}
}
}
@@ -406,58 +407,58 @@
// if we've already full-checked this grammar, then
// skip the EDC constraint
if (!fullChecked) {
- // 1. Element Decl Consistent
- if (types[j].fParticle!=null) {
- elemTable.clear();
- try {
- checkElementDeclsConsistent(types[j], types[j].fParticle,
- elemTable, SGHandler);
- }
- catch (XMLSchemaException e) {
- reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
+ // 1. Element Decl Consistent
+ if (types[j].fParticle!=null) {
+ elemTable.clear();
+ try {
+ checkElementDeclsConsistent(types[j], types[j].fParticle,
+ elemTable, SGHandler);
+ }
+ catch (XMLSchemaException e) {
+ reportSchemaError(errorReporter, ctLocators[j],
+ e.getKey(),
+ e.getArgs());
+ }
}
- }
}
// 2. Particle Derivation
if (types[j].fBaseType != null &&
- types[j].fBaseType != SchemaGrammar.fAnyType &&
- types[j].fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
- (types[j].fBaseType instanceof XSComplexTypeDecl)) {
-
- XSParticleDecl derivedParticle=types[j].fParticle;
- XSParticleDecl baseParticle=
- ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle;
- if (derivedParticle==null) {
- if (baseParticle!=null && !baseParticle.emptiable()) {
- reportSchemaError(errorReporter,ctLocators[j],
- "derivation-ok-restriction.5.3.2",
- new Object[]{types[j].fName, types[j].fBaseType.getName()});
- }
- }
- else if (baseParticle!=null) {
- try {
- particleValidRestriction(types[j].fParticle,
- SGHandler,
- ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle,
- SGHandler);
- } catch (XMLSchemaException e) {
- reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
- reportSchemaError(errorReporter, ctLocators[j],
- "derivation-ok-restriction.5.4.2",
- new Object[]{types[j].fName});
- }
- }
- else {
- reportSchemaError(errorReporter, ctLocators[j],
- "derivation-ok-restriction.5.4.2",
- new Object[]{types[j].fName});
- }
+ types[j].fBaseType != SchemaGrammar.fAnyType &&
+ types[j].fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
+ (types[j].fBaseType instanceof XSComplexTypeDecl)) {
+
+ XSParticleDecl derivedParticle=types[j].fParticle;
+ XSParticleDecl baseParticle=
+ ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle;
+ if (derivedParticle==null) {
+ if (baseParticle!=null && !baseParticle.emptiable()) {
+ reportSchemaError(errorReporter,ctLocators[j],
+ "derivation-ok-restriction.5.3.2",
+ new Object[]{types[j].fName, types[j].fBaseType.getName()});
+ }
+ }
+ else if (baseParticle!=null) {
+ try {
+ particleValidRestriction(types[j].fParticle,
+ SGHandler,
+ ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle,
+ SGHandler);
+ } catch (XMLSchemaException e) {
+ reportSchemaError(errorReporter, ctLocators[j],
+ e.getKey(),
+ e.getArgs());
+ reportSchemaError(errorReporter, ctLocators[j],
+ "derivation-ok-restriction.5.4.2",
+ new Object[]{types[j].fName});
+ }
+ }
+ else {
+ reportSchemaError(errorReporter, ctLocators[j],
+ "derivation-ok-restriction.5.4.2",
+ new Object[]{types[j].fName});
+ }
}
// 3. UPA
// get the content model and check UPA
@@ -468,8 +469,8 @@
further = cm.checkUniqueParticleAttribution(SGHandler);
} catch (XMLSchemaException e) {
reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
+ e.getKey(),
+ e.getArgs());
}
}
// now report all errors
@@ -502,923 +503,920 @@
/*
Check that a given particle is a valid restriction of a base particle.
- */
+ */
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
- XSParticleDecl particle,
- SymbolHash elemDeclHash,
- SubstitutionGroupHandler sgHandler)
- throws XMLSchemaException {
-
- // check for elements in the tree with the same name and namespace
-
- int pType = particle.fType;
-
- if (pType == XSParticleDecl.PARTICLE_WILDCARD)
- return;
-
- if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl elem = (XSElementDecl)(particle.fValue);
- findElemInTable(type, elem, elemDeclHash);
-
- if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups.
- XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
- for (int i = 0; i < subGroup.length; i++) {
- findElemInTable(type, subGroup[i], elemDeclHash);
- }
- }
- return;
- }
-
- XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
+ XSParticleDecl particle,
+ SymbolHash elemDeclHash,
+ SubstitutionGroupHandler sgHandler)
+ throws XMLSchemaException {
+
+ // check for elements in the tree with the same name and namespace
+
+ int pType = particle.fType;
+
+ if (pType == XSParticleDecl.PARTICLE_WILDCARD)
+ return;
+
+ if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl elem = (XSElementDecl)(particle.fValue);
+ findElemInTable(type, elem, elemDeclHash);
+
+ if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups.
+ XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
+ for (int i = 0; i < subGroup.length; i++) {
+ findElemInTable(type, subGroup[i], elemDeclHash);
+ }
+ }
+ return;
+ }
+
+ XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
- SymbolHash elemDeclHash)
- throws XMLSchemaException {
+ SymbolHash elemDeclHash)
+ throws XMLSchemaException {
// How can we avoid this concat? LM.
String name = elem.fName + "," + elem.fTargetNamespace;
XSElementDecl existingElem = null;
if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
- // just add it in
- elemDeclHash.put(name, elem);
+ // just add it in
+ elemDeclHash.put(name, elem);
}
else {
- // If this is the same check element, we're O.K.
- if (elem == existingElem)
- return;
+ // If this is the same check element, we're O.K.
+ if (elem == existingElem)
+ return;
+
+ if (elem.fType != existingElem.fType) {
+ // Types are not the same
+ throw new XMLSchemaException("cos-element-consistent",
+ new Object[] {type.fName, elem.fName});
- if (elem.fType != existingElem.fType) {
- // Types are not the same
- throw new XMLSchemaException("cos-element-consistent",
- new Object[] {type.fName, elem.fName});
-
- }
+ }
}
}
- /*
- Check that a given particle is a valid restriction of a base particle.
-
- IHR: 2006/11/17
- Returns a boolean indicating if there has been expansion of substitution group
- in the bParticle.
- With this information the checkRecurseLax function knows when is
- to keep the order and when to ignore it.
- */
+ // Check that a given particle is a valid restriction of a base particle.
+ //
+ // IHR: 2006/11/17
+ // Returns a boolean indicating if there has been expansion of substitution group
+ // in the bParticle.
+ // With this information the checkRecurseLax function knows when is
+ // to keep the order and when to ignore it.
private static boolean particleValidRestriction(XSParticleDecl dParticle,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl bParticle,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
- return particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true);
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl bParticle,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+ return particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true);
}
private static boolean particleValidRestriction(XSParticleDecl dParticle,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl bParticle,
- SubstitutionGroupHandler bSGHandler,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
-
- Vector dChildren = null;
- Vector bChildren = null;
- int dMinEffectiveTotalRange=OCCURRENCE_UNKNOWN;
- int dMaxEffectiveTotalRange=OCCURRENCE_UNKNOWN;
-
- // By default there has been no expansion
- boolean bExpansionHappened = false;
-
- // Check for empty particles. If either base or derived particle is empty,
- // (and the other isn't) it's an error.
- if (dParticle.isEmpty() && !bParticle.emptiable()) {
- throw new XMLSchemaException("cos-particle-restrict.a", null);
- }
- else if (!dParticle.isEmpty() && bParticle.isEmpty()) {
- throw new XMLSchemaException("cos-particle-restrict.b", null);
- }
-
- //
- // Do setup prior to invoking the Particle (Restriction) cases.
- // This involves:
- // - removing pointless occurrences for groups, and retrieving a vector of
- // non-pointless children
- // - turning top-level elements with substitution groups into CHOICE groups.
- //
-
- short dType = dParticle.fType;
- //
- // Handle pointless groups for the derived particle
- //
- if (dType == XSParticleDecl.PARTICLE_MODELGROUP) {
- dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
-
- // Find a group, starting with this particle, with more than 1 child. There
- // may be none, and the particle of interest trivially becomes an element or
- // wildcard.
- XSParticleDecl dtmp = getNonUnaryGroup(dParticle);
- if (dtmp != dParticle) {
- // Particle has been replaced. Retrieve new type info.
- dParticle = dtmp;
- dType = dParticle.fType;
- if (dType == XSParticleDecl.PARTICLE_MODELGROUP)
- dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
- }
-
- // Fill in a vector with the children of the particle, removing any
- // pointless model groups in the process.
- dChildren = removePointlessChildren(dParticle);
- }
-
- int dMinOccurs = dParticle.fMinOccurs;
- int dMaxOccurs = dParticle.fMaxOccurs;
-
- //
- // For elements which are the heads of substitution groups, treat as CHOICE
- //
- if (dSGHandler != null && dType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl dElement = (XSElementDecl)dParticle.fValue;
-
- if (dElement.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups. Treat any element that has a
- // subsitution group as a choice. Fill in the children vector with the
- // members of the substitution group
- XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement);
- if (subGroup.length >0 ) {
- // Now, set the type to be CHOICE. The "group" will have the same
- // occurrence information as the original particle.
- dType = XSModelGroupImpl.MODELGROUP_CHOICE;
- dMinEffectiveTotalRange = dMinOccurs;
- dMaxEffectiveTotalRange = dMaxOccurs;
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl bParticle,
+ SubstitutionGroupHandler bSGHandler,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
+
+ Vector dChildren = null;
+ Vector bChildren = null;
+ int dMinEffectiveTotalRange=OCCURRENCE_UNKNOWN;
+ int dMaxEffectiveTotalRange=OCCURRENCE_UNKNOWN;
+
+ // By default there has been no expansion
+ boolean bExpansionHappened = false;
+
+ // Check for empty particles. If either base or derived particle is empty,
+ // (and the other isn't) it's an error.
+ if (dParticle.isEmpty() && !bParticle.emptiable()) {
+ throw new XMLSchemaException("cos-particle-restrict.a", null);
+ }
+ else if (!dParticle.isEmpty() && bParticle.isEmpty()) {
+ throw new XMLSchemaException("cos-particle-restrict.b", null);
+ }
+
+ //
+ // Do setup prior to invoking the Particle (Restriction) cases.
+ // This involves:
+ // - removing pointless occurrences for groups, and retrieving a vector of
+ // non-pointless children
+ // - turning top-level elements with substitution groups into CHOICE groups.
+ //
+
+ short dType = dParticle.fType;
+ //
+ // Handle pointless groups for the derived particle
+ //
+ if (dType == XSParticleDecl.PARTICLE_MODELGROUP) {
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
+
+ // Find a group, starting with this particle, with more than 1 child. There
+ // may be none, and the particle of interest trivially becomes an element or
+ // wildcard.
+ XSParticleDecl dtmp = getNonUnaryGroup(dParticle);
+ if (dtmp != dParticle) {
+ // Particle has been replaced. Retrieve new type info.
+ dParticle = dtmp;
+ dType = dParticle.fType;
+ if (dType == XSParticleDecl.PARTICLE_MODELGROUP)
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
+ }
- // Fill in the vector of children
- dChildren = new Vector(subGroup.length+1);
- for (int i = 0; i < subGroup.length; i++) {
- addElementToParticleVector(dChildren, subGroup[i]);
+ // Fill in a vector with the children of the particle, removing any
+ // pointless model groups in the process.
+ dChildren = removePointlessChildren(dParticle);
+ }
+
+ int dMinOccurs = dParticle.fMinOccurs;
+ int dMaxOccurs = dParticle.fMaxOccurs;
+
+ //
+ // For elements which are the heads of substitution groups, treat as CHOICE
+ //
+ if (dSGHandler != null && dType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl dElement = (XSElementDecl)dParticle.fValue;
+
+ if (dElement.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups. Treat any element that has a
+ // subsitution group as a choice. Fill in the children vector with the
+ // members of the substitution group
+ XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement);
+ if (subGroup.length >0 ) {
+ // Now, set the type to be CHOICE. The "group" will have the same
+ // occurrence information as the original particle.
+ dType = XSModelGroupImpl.MODELGROUP_CHOICE;
+ dMinEffectiveTotalRange = dMinOccurs;
+ dMaxEffectiveTotalRange = dMaxOccurs;
+
+ // Fill in the vector of children
+ dChildren = new Vector(subGroup.length+1);
+ for (int i = 0; i < subGroup.length; i++) {
+ addElementToParticleVector(dChildren, subGroup[i]);
+ }
+ addElementToParticleVector(dChildren, dElement);
+ Collections.sort(dChildren, ELEMENT_PARTICLE_COMPARATOR);
+
+ // Set the handler to null, to indicate that we've finished handling
+ // substitution groups for this particle.
+ dSGHandler = null;
}
- addElementToParticleVector(dChildren, dElement);
- Collections.sort(dChildren, ELEMENT_PARTICLE_COMPARATOR);
+ }
+ }
+
+ short bType = bParticle.fType;
+ //
+ // Handle pointless groups for the base particle
+ //
+ if (bType == XSParticleDecl.PARTICLE_MODELGROUP) {
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
+
+ // Find a group, starting with this particle, with more than 1 child. There
+ // may be none, and the particle of interest trivially becomes an element or
+ // wildcard.
+ XSParticleDecl btmp = getNonUnaryGroup(bParticle);
+ if (btmp != bParticle) {
+ // Particle has been replaced. Retrieve new type info.
+ bParticle = btmp;
+ bType = bParticle.fType;
+ if (bType == XSParticleDecl.PARTICLE_MODELGROUP)
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
+ }
+
+ // Fill in a vector with the children of the particle, removing any
+ // pointless model groups in the process.
+ bChildren = removePointlessChildren(bParticle);
+ }
+
+ int bMinOccurs = bParticle.fMinOccurs;
+ int bMaxOccurs = bParticle.fMaxOccurs;
+
+ if (bSGHandler != null && bType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl bElement = (XSElementDecl)bParticle.fValue;
+
+ if (bElement.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups. Treat any element that has a
+ // subsitution group as a choice. Fill in the children vector with the
+ // members of the substitution group
+ XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement);
+ if (bsubGroup.length >0 ) {
+ // Now, set the type to be CHOICE
+ bType = XSModelGroupImpl.MODELGROUP_CHOICE;
+
+ bChildren = new Vector(bsubGroup.length+1);
+ for (int i = 0; i < bsubGroup.length; i++) {
+ addElementToParticleVector(bChildren, bsubGroup[i]);
+ }
+ addElementToParticleVector(bChildren, bElement);
+ Collections.sort(bChildren, ELEMENT_PARTICLE_COMPARATOR);
+ // Set the handler to null, to indicate that we've finished handling
+ // substitution groups for this particle.
+ bSGHandler = null;
- // Set the handler to null, to indicate that we've finished handling
- // substitution groups for this particle.
- dSGHandler = null;
- }
- }
- }
-
- short bType = bParticle.fType;
- //
- // Handle pointless groups for the base particle
- //
- if (bType == XSParticleDecl.PARTICLE_MODELGROUP) {
- bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
-
- // Find a group, starting with this particle, with more than 1 child. There
- // may be none, and the particle of interest trivially becomes an element or
- // wildcard.
- XSParticleDecl btmp = getNonUnaryGroup(bParticle);
- if (btmp != bParticle) {
- // Particle has been replaced. Retrieve new type info.
- bParticle = btmp;
- bType = bParticle.fType;
- if (bType == XSParticleDecl.PARTICLE_MODELGROUP)
- bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
- }
-
- // Fill in a vector with the children of the particle, removing any
- // pointless model groups in the process.
- bChildren = removePointlessChildren(bParticle);
- }
-
- int bMinOccurs = bParticle.fMinOccurs;
- int bMaxOccurs = bParticle.fMaxOccurs;
-
- if (bSGHandler != null && bType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl bElement = (XSElementDecl)bParticle.fValue;
-
- if (bElement.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups. Treat any element that has a
- // subsitution group as a choice. Fill in the children vector with the
- // members of the substitution group
- XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement);
- if (bsubGroup.length >0 ) {
- // Now, set the type to be CHOICE
- bType = XSModelGroupImpl.MODELGROUP_CHOICE;
-
- bChildren = new Vector(bsubGroup.length+1);
- for (int i = 0; i < bsubGroup.length; i++) {
- addElementToParticleVector(bChildren, bsubGroup[i]);
- }
- addElementToParticleVector(bChildren, bElement);
- Collections.sort(bChildren, ELEMENT_PARTICLE_COMPARATOR);
- // Set the handler to null, to indicate that we've finished handling
- // substitution groups for this particle.
- bSGHandler = null;
-
- // if we are here expansion of bParticle happened
- bExpansionHappened = true;
- }
- }
- }
-
- //
- // O.K. - Figure out which particle derivation rule applies and call it
- //
- switch (dType) {
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- switch (bType) {
-
- // Elt:Elt NameAndTypeOK
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- checkNameAndTypeOK((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
- (XSElementDecl)bParticle.fValue,bMinOccurs,bMaxOccurs);
- return bExpansionHappened;
- }
-
- // Elt:Any NSCompat
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- checkNSCompat((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
- (XSWildcardDecl)bParticle.fValue,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return bExpansionHappened;
- }
-
- // Elt:All RecurseAsIfGroup
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- // Treat the element as if it were in a group of the same type
- // as the base Particle
- dChildren = new Vector();
- dChildren.addElement(dParticle);
-
- checkRecurseLax(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- // Treat the element as if it were in a group of the same type
- // as the base Particle
- dChildren = new Vector();
- dChildren.addElement(dParticle);
-
- checkRecurse(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- switch (bType) {
-
- // Any:Any NSSubset
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- checkNSSubset((XSWildcardDecl)dParticle.fValue, dMinOccurs, dMaxOccurs,
- (XSWildcardDecl)bParticle.fValue, bMinOccurs, bMaxOccurs);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSModelGroupImpl.MODELGROUP_ALL:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"any:choice,sequence,all,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- switch (bType) {
-
- // All:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
-
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"all:choice,sequence,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- switch (bType) {
-
- // Choice:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"choice:all,sequence,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
-
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- {
- switch (bType) {
-
- // Choice:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- {
- checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- int min1 = dMinOccurs * dChildren.size();
- int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
- dMaxOccurs : dMaxOccurs * dChildren.size();
- checkMapAndSum(dChildren, min1, max1, dSGHandler,
+ // if we are here expansion of bParticle happened
+ bExpansionHappened = true;
+ }
+ }
+ }
+
+ //
+ // O.K. - Figure out which particle derivation rule applies and call it
+ //
+ switch (dType) {
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ switch (bType) {
+
+ // Elt:Elt NameAndTypeOK
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ checkNameAndTypeOK((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
+ (XSElementDecl)bParticle.fValue,bMinOccurs,bMaxOccurs);
+ return bExpansionHappened;
+ }
+
+ // Elt:Any NSCompat
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ checkNSCompat((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
+ (XSWildcardDecl)bParticle.fValue,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
+
+ // Elt:All RecurseAsIfGroup
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ // Treat the element as if it were in a group of the same type
+ // as the base Particle
+ dChildren = new Vector();
+ dChildren.addElement(dParticle);
+
+ checkRecurseLax(dChildren, 1, 1, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ // Treat the element as if it were in a group of the same type
+ // as the base Particle
+ dChildren = new Vector();
+ dChildren.addElement(dParticle);
+
+ checkRecurse(dChildren, 1, 1, dSGHandler,
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return bExpansionHappened;
- }
+ return bExpansionHappened;
+ }
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"seq:elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
}
- }
- }
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ switch (bType) {
+
+ // Any:Any NSSubset
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ checkNSSubset((XSWildcardDecl)dParticle.fValue, dMinOccurs, dMaxOccurs,
+ (XSWildcardDecl)bParticle.fValue, bMinOccurs, bMaxOccurs);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"any:choice,sequence,all,elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ switch (bType) {
+
+ // All:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
+
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"all:choice,sequence,elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ switch (bType) {
+
+ // Choice:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
+
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"choice:all,sequence,elt"});
+ }
- return bExpansionHappened;
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ {
+ switch (bType) {
+
+ // Choice:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
+
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ {
+ checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ int min1 = dMinOccurs * dChildren.size();
+ int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
+ dMaxOccurs : dMaxOccurs * dChildren.size();
+ checkMapAndSum(dChildren, min1, max1, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"seq:elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ }
+
+ return bExpansionHappened;
}
private static void addElementToParticleVector (Vector v, XSElementDecl d) {
- XSParticleDecl p = new XSParticleDecl();
- p.fValue = d;
- p.fType = XSParticleDecl.PARTICLE_ELEMENT;
- v.addElement(p);
+ XSParticleDecl p = new XSParticleDecl();
+ p.fValue = d;
+ p.fType = XSParticleDecl.PARTICLE_ELEMENT;
+ v.addElement(p);
}
private static XSParticleDecl getNonUnaryGroup(XSParticleDecl p) {
- if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
- p.fType == XSParticleDecl.PARTICLE_WILDCARD)
- return p;
-
- if (p.fMinOccurs==1 && p.fMaxOccurs==1 &&
- p.fValue!=null && ((XSModelGroupImpl)p.fValue).fParticleCount == 1)
- return getNonUnaryGroup(((XSModelGroupImpl)p.fValue).fParticles[0]);
- else
- return p;
+ if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
+ p.fType == XSParticleDecl.PARTICLE_WILDCARD)
+ return p;
+
+ if (p.fMinOccurs==1 && p.fMaxOccurs==1 &&
+ p.fValue!=null && ((XSModelGroupImpl)p.fValue).fParticleCount == 1)
+ return getNonUnaryGroup(((XSModelGroupImpl)p.fValue).fParticles[0]);
+ else
+ return p;
}
private static Vector removePointlessChildren(XSParticleDecl p) {
+ if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
+ p.fType == XSParticleDecl.PARTICLE_WILDCARD)
+ return null;
- if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
- p.fType == XSParticleDecl.PARTICLE_WILDCARD)
- return null;
-
- Vector children = new Vector();
+ Vector children = new Vector();
- XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- gatherChildren(group.fCompositor, group.fParticles[i], children);
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ gatherChildren(group.fCompositor, group.fParticles[i], children);
- return children;
+ return children;
}
private static void gatherChildren(int parentType, XSParticleDecl p, Vector children) {
- int min = p.fMinOccurs;
- int max = p.fMaxOccurs;
- int type = p.fType;
- if (type == XSParticleDecl.PARTICLE_MODELGROUP)
- type = ((XSModelGroupImpl)p.fValue).fCompositor;
-
- if (type == XSParticleDecl.PARTICLE_ELEMENT ||
- type== XSParticleDecl.PARTICLE_WILDCARD) {
- children.addElement(p);
- return;
- }
-
- if (! (min==1 && max==1)) {
- children.addElement(p);
- }
- else if (parentType == type) {
- XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- gatherChildren(type, group.fParticles[i], children);
- }
- else if (!p.isEmpty()) {
- children.addElement(p);
- }
+ int min = p.fMinOccurs;
+ int max = p.fMaxOccurs;
+ int type = p.fType;
+ if (type == XSParticleDecl.PARTICLE_MODELGROUP)
+ type = ((XSModelGroupImpl)p.fValue).fCompositor;
+
+ if (type == XSParticleDecl.PARTICLE_ELEMENT ||
+ type== XSParticleDecl.PARTICLE_WILDCARD) {
+ children.addElement(p);
+ return;
+ }
+
+ if (! (min==1 && max==1)) {
+ children.addElement(p);
+ }
+ else if (parentType == type) {
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ gatherChildren(type, group.fParticles[i], children);
+ }
+ else if (!p.isEmpty()) {
+ children.addElement(p);
+ }
}
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
- XSElementDecl bElement, int bMin, int bMax)
- throws XMLSchemaException {
+ XSElementDecl bElement, int bMin, int bMax)
+ throws XMLSchemaException {
+
+
+ //
+ // Check that the names are the same
+ //
+ if (dElement.fName != bElement.fName ||
+ dElement.fTargetNamespace != bElement.fTargetNamespace) {
+ throw new XMLSchemaException(
+ "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
+ dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
+ }
+
+ //
+ // Check nillable
+ //
+ if (!bElement.getNillable() && dElement.getNillable()) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.2",
+ new Object[]{dElement.fName});
+ }
+
+ //
+ // Check occurrence range
+ //
+ if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.3",
+ new Object[]{
+ dElement.fName,
+ Integer.toString(dMin),
+ dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
+ Integer.toString(bMin),
+ bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
+ }
+
+ //
+ // Check for consistent fixed values
+ //
+ if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
+ // derived one has to have a fixed value
+ if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
+ new Object[]{dElement.fName, bElement.fDefault.stringValue()});
+ }
+ // get simple type
+ boolean isSimple = false;
+ if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
+ ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
+ isSimple = true;
+ }
+
+ // if there is no simple type, then compare based on string
+ if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
+ isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
+ new Object[]{dElement.fName,
+ dElement.fDefault.stringValue(),
+ bElement.fDefault.stringValue()});
+ }
+ }
- //
- // Check that the names are the same
- //
- if (dElement.fName != bElement.fName ||
- dElement.fTargetNamespace != bElement.fTargetNamespace) {
- throw new XMLSchemaException(
- "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
- dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
- }
-
- //
- // Check nillable
- //
- if (!bElement.getNillable() && dElement.getNillable()) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.2",
- new Object[]{dElement.fName});
- }
-
- //
- // Check occurrence range
- //
- if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.3",
- new Object[]{
- dElement.fName,
- Integer.toString(dMin),
- dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
- Integer.toString(bMin),
- bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
- }
-
- //
- // Check for consistent fixed values
- //
- if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
- // derived one has to have a fixed value
- if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
- new Object[]{dElement.fName, bElement.fDefault.stringValue()});
- }
-
- // get simple type
- boolean isSimple = false;
- if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
- ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
- isSimple = true;
- }
-
- // if there is no simple type, then compare based on string
- if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
- isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
- new Object[]{dElement.fName,
- dElement.fDefault.stringValue(),
- bElement.fDefault.stringValue()});
- }
- }
-
- //
- // Check identity constraints
- //
- checkIDConstraintRestriction(dElement, bElement);
-
- //
- // Check for disallowed substitutions
- //
- int blockSet1 = dElement.fBlock;
- int blockSet2 = bElement.fBlock;
- if (((blockSet1 & blockSet2)!=blockSet2) ||
- (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
- throw new XMLSchemaException("rcase-NameAndTypeOK.6",
- new Object[]{dElement.fName});
-
-
- //
- // Check that the derived element's type is derived from the base's.
- //
- if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
- (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.7",
- new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
- }
+ //
+ // Check identity constraints
+ //
+ checkIDConstraintRestriction(dElement, bElement);
+
+ //
+ // Check for disallowed substitutions
+ //
+ int blockSet1 = dElement.fBlock;
+ int blockSet2 = bElement.fBlock;
+ if (((blockSet1 & blockSet2)!=blockSet2) ||
+ (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
+ throw new XMLSchemaException("rcase-NameAndTypeOK.6",
+ new Object[]{dElement.fName});
+
+
+ //
+ // Check that the derived element's type is derived from the base's.
+ //
+ if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
+ (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.7",
+ new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
+ }
}
private static void checkIDConstraintRestriction(XSElementDecl derivedElemDecl,
- XSElementDecl baseElemDecl)
- throws XMLSchemaException {
+ XSElementDecl baseElemDecl)
+ throws XMLSchemaException {
// TODO
} // checkIDConstraintRestriction
private static boolean checkOccurrenceRange(int min1, int max1, int min2, int max2) {
- if ((min1 >= min2) &&
- ((max2==SchemaSymbols.OCCURRENCE_UNBOUNDED) ||
- (max1!=SchemaSymbols.OCCURRENCE_UNBOUNDED && max1<=max2)))
- return true;
- else
- return false;
+ if ((min1 >= min2) &&
+ ((max2==SchemaSymbols.OCCURRENCE_UNBOUNDED) ||
+ (max1!=SchemaSymbols.OCCURRENCE_UNBOUNDED && max1<=max2)))
+ return true;
+ else
+ return false;
}
private static void checkNSCompat(XSElementDecl elem, int min1, int max1,
- XSWildcardDecl wildcard, int min2, int max2,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
-
- // check Occurrence ranges
- if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSCompat.2",
- new Object[]{
- elem.fName,
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- // check wildcard allows namespace of element
- if (!wildcard.allowNamespace(elem.fTargetNamespace)) {
- throw new XMLSchemaException("rcase-NSCompat.1",
- new Object[]{elem.fName,elem.fTargetNamespace});
- }
+ XSWildcardDecl wildcard, int min2, int max2,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
+
+ // check Occurrence ranges
+ if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSCompat.2",
+ new Object[]{
+ elem.fName,
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ // check wildcard allows namespace of element
+ if (!wildcard.allowNamespace(elem.fTargetNamespace)) {
+ throw new XMLSchemaException("rcase-NSCompat.1",
+ new Object[]{elem.fName,elem.fTargetNamespace});
+ }
}
private static void checkNSSubset(XSWildcardDecl dWildcard, int min1, int max1,
- XSWildcardDecl bWildcard, int min2, int max2)
- throws XMLSchemaException {
+ XSWildcardDecl bWildcard, int min2, int max2)
+ throws XMLSchemaException {
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSSubset.2", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- // check wildcard subset
- if (!dWildcard.isSubsetOf(bWildcard)) {
- throw new XMLSchemaException("rcase-NSSubset.1", null);
- }
-
- if (dWildcard.weakerProcessContents(bWildcard)) {
- throw new XMLSchemaException("rcase-NSSubset.3",
- new Object[]{dWildcard.getProcessContentsAsString(),
- bWildcard.getProcessContentsAsString()});
- }
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSSubset.2", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ // check wildcard subset
+ if (!dWildcard.isSubsetOf(bWildcard)) {
+ throw new XMLSchemaException("rcase-NSSubset.1", null);
+ }
+
+ if (dWildcard.weakerProcessContents(bWildcard)) {
+ throw new XMLSchemaException("rcase-NSSubset.3",
+ new Object[]{dWildcard.getProcessContentsAsString(),
+ bWildcard.getProcessContentsAsString()});
+ }
}
private static void checkNSRecurseCheckCardinality(Vector children, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl wildcard, int min2, int max2,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
-
-
- // check Occurrence ranges
- if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.2", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- // Check that each member of the group is a valid restriction of the wildcard
- int count = children.size();
- try {
- for (int i = 0; i < count; i++) {
- XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i);
- particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
-
- }
- }
- // REVISIT: should we really just ignore original cause of this error?
- // how can we report it?
- catch (XMLSchemaException e) {
- throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.1", null);
- }
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl wildcard, int min2, int max2,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
+
+
+ // check Occurrence ranges
+ if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.2", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ // Check that each member of the group is a valid restriction of the wildcard
+ int count = children.size();
+ try {
+ for (int i = 0; i < count; i++) {
+ XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i);
+ particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
+
+ }
+ }
+ // REVISIT: should we really just ignore original cause of this error?
+ // how can we report it?
+ catch (XMLSchemaException e) {
+ throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.1", null);
+ }
}
private static void checkRecurse(Vector dChildren, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
-
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-Recurse.1", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- int count1= dChildren.size();
- int count2= bChildren.size();
-
- int current = 0;
- label: for (int i = 0; i<count1; i++) {
-
- XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
- for (int j = current; j<count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- current +=1;
- try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
- continue label;
- }
- catch (XMLSchemaException e) {
- if (!particle2.emptiable())
- throw new XMLSchemaException("rcase-Recurse.2", null);
- }
+ SubstitutionGroupHandler dSGHandler,
+ Vector bChildren, int min2, int max2,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-Recurse.1", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ int count1= dChildren.size();
+ int count2= bChildren.size();
+
+ int current = 0;
+ label: for (int i = 0; i<count1; i++) {
+
+ XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
+ for (int j = current; j<count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ current +=1;
+ try {
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ continue label;
+ }
+ catch (XMLSchemaException e) {
+ if (!particle2.emptiable())
+ throw new XMLSchemaException("rcase-Recurse.2", null);
+ }
+ }
+ throw new XMLSchemaException("rcase-Recurse.2", null);
}
- throw new XMLSchemaException("rcase-Recurse.2", null);
- }
- // Now, see if there are some elements in the base we didn't match up
- for (int j=current; j < count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- if (!particle2.emptiable()) {
- throw new XMLSchemaException("rcase-Recurse.2", null);
+ // Now, see if there are some elements in the base we didn't match up
+ for (int j=current; j < count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ if (!particle2.emptiable()) {
+ throw new XMLSchemaException("rcase-Recurse.2", null);
+ }
}
- }
}
private static void checkRecurseUnordered(Vector dChildren, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
-
-
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-RecurseUnordered.1", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- int count1= dChildren.size();
- int count2 = bChildren.size();
-
- boolean foundIt[] = new boolean[count2];
-
- label: for (int i = 0; i<count1; i++) {
- XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
-
- for (int j = 0; j<count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
- if (foundIt[j])
- throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
- else
- foundIt[j]=true;
+ SubstitutionGroupHandler dSGHandler,
+ Vector bChildren, int min2, int max2,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+
+
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-RecurseUnordered.1", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ int count1= dChildren.size();
+ int count2 = bChildren.size();
+
+ boolean foundIt[] = new boolean[count2];
+
+ label: for (int i = 0; i<count1; i++) {
+ XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
+
+ for (int j = 0; j<count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ try {
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ if (foundIt[j])
+ throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
+ else
+ foundIt[j]=true;
- continue label;
- }
- catch (XMLSchemaException e) {
- }
- }
- // didn't find a match. Detect an error
- throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
- }
-
- // Now, see if there are some elements in the base we didn't match up
- for (int j=0; j < count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- if (!foundIt[j] && !particle2.emptiable()) {
- throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
+ continue label;
+ }
+ catch (XMLSchemaException e) {
+ }
+ }
+ // didn't find a match. Detect an error
+ throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
+ }
+
+ // Now, see if there are some elements in the base we didn't match up
+ for (int j=0; j < count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ if (!foundIt[j] && !particle2.emptiable()) {
+ throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
+ }
}
- }
}
private static void checkRecurseLax(Vector dChildren, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
-
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-RecurseLax.1", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- int count1= dChildren.size();
- int count2 = bChildren.size();
-
- int current = 0;
- label: for (int i = 0; i<count1; i++) {
-
- XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
- for (int j = current; j<count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- current +=1;
- try {
- // IHR: go back one element on b list because the next element may match
- // this as well.
- if (particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler))
- current--;
- continue label;
- }
- catch (XMLSchemaException e) {
- }
- }
- // didn't find a match. Detect an error
- throw new XMLSchemaException("rcase-RecurseLax.2", null);
+ SubstitutionGroupHandler dSGHandler,
+ Vector bChildren, int min2, int max2,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-RecurseLax.1", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ int count1= dChildren.size();
+ int count2 = bChildren.size();
+
+ int current = 0;
+ label: for (int i = 0; i<count1; i++) {
+
+ XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
+ for (int j = current; j<count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ current +=1;
+ try {
+ // IHR: go back one element on b list because the next element may match
+ // this as well.
+ if (particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler))
+ current--;
+ continue label;
+ }
+ catch (XMLSchemaException e) {
+ }
+ }
+ // didn't find a match. Detect an error
+ throw new XMLSchemaException("rcase-RecurseLax.2", null);
- }
+ }
}
private static void checkMapAndSum(Vector dChildren, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
-
- // See if the sequence group is a valid restriction of the choice
-
- // Here is an example of a valid restriction:
- // <choice minOccurs="2">
- // <a/>
- // <b/>
- // <c/>
- // </choice>
- //
- // <sequence>
- // <b/>
- // <a/>
- // </sequence>
-
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-MapAndSum.2",
- new Object[]{Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
-
- int count1 = dChildren.size();
- int count2 = bChildren.size();
-
- label: for (int i = 0; i<count1; i++) {
-
- XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
- for (int j = 0; j<count2; j++) {
- XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
- try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
- continue label;
- }
- catch (XMLSchemaException e) {
- }
- }
- // didn't find a match. Detect an error
- throw new XMLSchemaException("rcase-MapAndSum.1", null);
- }
+ SubstitutionGroupHandler dSGHandler,
+ Vector bChildren, int min2, int max2,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+
+ // See if the sequence group is a valid restriction of the choice
+
+ // Here is an example of a valid restriction:
+ // <choice minOccurs="2">
+ // <a/>
+ // <b/>
+ // <c/>
+ // </choice>
+ //
+ // <sequence>
+ // <b/>
+ // <a/>
+ // </sequence>
+
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-MapAndSum.2",
+ new Object[]{Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
+
+ int count1 = dChildren.size();
+ int count2 = bChildren.size();
+
+ label: for (int i = 0; i<count1; i++) {
+
+ XSParticleDecl particle1 = (XSParticleDecl)dChildren.elementAt(i);
+ for (int j = 0; j<count2; j++) {
+ XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
+ try {
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ continue label;
+ }
+ catch (XMLSchemaException e) {
+ }
+ }
+ // didn't find a match. Detect an error
+ throw new XMLSchemaException("rcase-MapAndSum.1", null);
+ }
}
// to check whether two element overlap, as defined in constraint UPA
public static boolean overlapUPA(XSElementDecl element1,
- XSElementDecl element2,
- SubstitutionGroupHandler sgHandler) {
+ XSElementDecl element2,
+ SubstitutionGroupHandler sgHandler) {
// if the two element have the same name and namespace,
if (element1.fName == element2.fName &&
- element1.fTargetNamespace == element2.fTargetNamespace) {
+ element1.fTargetNamespace == element2.fTargetNamespace) {
return true;
}
@@ -1427,7 +1425,7 @@
XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element1);
for (int i = subGroup.length-1; i >= 0; i--) {
if (subGroup[i].fName == element2.fName &&
- subGroup[i].fTargetNamespace == element2.fTargetNamespace) {
+ subGroup[i].fTargetNamespace == element2.fTargetNamespace) {
return true;
}
}
@@ -1437,7 +1435,7 @@
subGroup = sgHandler.getSubstitutionGroup(element2);
for (int i = subGroup.length-1; i >= 0; i--) {
if (subGroup[i].fName == element1.fName &&
- subGroup[i].fTargetNamespace == element1.fTargetNamespace) {
+ subGroup[i].fTargetNamespace == element1.fTargetNamespace) {
return true;
}
}
@@ -1448,8 +1446,8 @@
// to check whether an element overlaps with a wildcard,
// as defined in constraint UPA
public static boolean overlapUPA(XSElementDecl element,
- XSWildcardDecl wildcard,
- SubstitutionGroupHandler sgHandler) {
+ XSWildcardDecl wildcard,
+ SubstitutionGroupHandler sgHandler) {
// if the wildcard allows the element
if (wildcard.allowNamespace(element.fTargetNamespace))
return true;
@@ -1465,12 +1463,12 @@
}
public static boolean overlapUPA(XSWildcardDecl wildcard1,
- XSWildcardDecl wildcard2) {
+ XSWildcardDecl wildcard2) {
// if the intersection of the two wildcard is not empty list
XSWildcardDecl intersect = wildcard1.performIntersectionWith(wildcard2, wildcard1.fProcessContents);
if (intersect == null ||
- intersect.fType != XSWildcardDecl.NSCONSTRAINT_LIST ||
- intersect.fNamespaceList.length != 0) {
+ intersect.fType != XSWildcardDecl.NSCONSTRAINT_LIST ||
+ intersect.fNamespaceList.length != 0) {
return true;
}
@@ -1479,25 +1477,28 @@
// call one of the above methods according to the type of decls
[... 38 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org