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 2008/09/15 23:34:09 UTC
svn commit: r695639 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl:
msg/XMLSchemaMessages.properties xs/traversers/XSDComplexTypeTraverser.java
Author: knoaman
Date: Mon Sep 15 14:34:08 2008
New Revision: 695639
URL: http://svn.apache.org/viewvc?rev=695639&view=rev
Log:
Allow extension of <all> model groups
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=695639&r1=695638&r2=695639&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Mon Sep 15 14:34:08 2008
@@ -175,6 +175,7 @@
cos-element-consistent = cos-element-consistent: Error for type ''{0}''. Multiple elements with name ''{1}'', with different types, appear in the model group.
cos-list-of-atomic = cos-list-of-atomic: In the definition of list type ''{0}'', type ''{1}'' is an invalid list element type because it is not atomic (''{1}'' is either a list type, or a union type which contains a list).
cos-nonambig = cos-nonambig: {0} and {1} (or elements from their substitution group) violate \"Unique Particle Attribution\". During validation against this schema, ambiguity would be created for those two particles.
+ cos-particle-extends.3.1 = cos-particle-extends.3.1: When both a derived type and its base have particles with <all> as their {term}s, the minOccurs of the derived particle needs to be equal to that of its base.
cos-particle-restrict.a = cos-particle-restrict.a: Derived particle is empty, and base is not emptiable.
cos-particle-restrict.b = cos-particle-restrict.b: Base particle is empty, but derived particle is not.
cos-particle-restrict.2 = cos-particle-restrict.2: Forbidden particle restriction: ''{0}''.
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=695639&r1=695638&r2=695639&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Mon Sep 15 14:34:08 2008
@@ -193,8 +193,8 @@
final short ocMode = modeAttr.shortValue();
if (isDefault) {
- final Boolean appliesToEmptyAttr = ((Boolean) attrValues[XSAttributeChecker.ATTIDX_APPLIESTOEMPTY]);
- ocDecl.fAppliesToEmpty = appliesToEmptyAttr.booleanValue();
+ final Boolean appliesToEmptyAttr = ((Boolean) attrValues[XSAttributeChecker.ATTIDX_APPLIESTOEMPTY]);
+ ocDecl.fAppliesToEmpty = appliesToEmptyAttr.booleanValue();
}
ocDecl.fMode = ocMode;
@@ -900,7 +900,7 @@
else {
// This is an EXTENSION
-
+
// Create the particle
if (fParticle == null) {
fContentType = baseType.getContentType();
@@ -930,37 +930,81 @@
throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.1.b",
new Object[]{fName}, complexContent);
}
-
+
// if the content of either type is an "all" model group, error.
- if (fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
- ((XSModelGroupImpl)fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL ||
- ((XSParticleDecl)baseType.getParticle()).fType == XSParticleDecl.PARTICLE_MODELGROUP &&
- ((XSModelGroupImpl)(((XSParticleDecl)baseType.getParticle())).fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
- fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
- fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
- throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
- new Object[]{}, complexContent);
+ boolean baseIsAll = (((XSParticleDecl)baseType.getParticle()).fType == XSParticleDecl.PARTICLE_MODELGROUP
+ && ((XSModelGroupImpl)(((XSParticleDecl)baseType.getParticle())).fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL);
+ boolean derivedIsAll = (fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP
+ && ((XSModelGroupImpl)fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL);
+
+ if (baseIsAll || derivedIsAll) {
+ // XML Schema 1.1
+ //
+ // 4.2.3.2 If the {term} of the base particle has {compositor} all
+ // and the {term} of the effective content also has {compositor}
+ // all, then a Particle whose properties are as follows:
+ // {min occurs}
+ // the {min occurs} of the effective content.
+ // {max occurs}
+ // 1
+ // {term}
+ // a model group whose {compositor} is all and whose {particles}
+ // are the {particles} of the {term} of the base particle followed
+ // by the {particles} of the {term} of the effective content.
+ if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && baseIsAll && derivedIsAll) {
+ // Schema Component Constraint: Particle Valid (Extension)
+ // 3.1 E's {min occurs} is the same as B's {min occurs}.
+ if (fParticle.fMinOccurs != baseContent.fMinOccurs) {
+ throw new ComplexTypeRecoverableError("cos-particle-extends.3.1",
+ new Object[]{}, complexContent);
+ }
+
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
+ group.fParticleCount = ((XSModelGroupImpl)baseContent.fValue).fParticleCount + ((XSModelGroupImpl)fParticle.fValue).fParticleCount;
+ group.fParticles = new XSParticleDecl[group.fParticleCount];
+ System.arraycopy(((XSModelGroupImpl)baseContent.fValue).fParticles, 0, group.fParticles, 0, ((XSModelGroupImpl)baseContent.fValue).fParticleCount);
+ System.arraycopy(((XSModelGroupImpl)fParticle.fValue).fParticles, 0, group.fParticles, ((XSModelGroupImpl)baseContent.fValue).fParticleCount, ((XSModelGroupImpl)fParticle.fValue).fParticleCount);
+ group.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ // the particle to contain the above all
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
+ particle.fValue = group;
+ particle.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ particle.fMinOccurs = fParticle.fMinOccurs;
+
+ fParticle = particle;
+ explicitOpenContent = (XSOpenContentDecl) baseType.getOpenContent();
+ }
+ else {
+ fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
+ fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
+ throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
+ new Object[]{}, complexContent);
+ }
}
// the "sequence" model group to contain both particles
- XSModelGroupImpl group = new XSModelGroupImpl();
- group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
- group.fParticleCount = 2;
- group.fParticles = new XSParticleDecl[2];
- group.fParticles[0] = (XSParticleDecl)baseType.getParticle();
- group.fParticles[1] = fParticle;
- group.fAnnotations = XSObjectListImpl.EMPTY_LIST;
- // the particle to contain the above sequence
- XSParticleDecl particle = new XSParticleDecl();
- particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
- particle.fValue = group;
- particle.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ else {
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
+ group.fParticleCount = 2;
+ group.fParticles = new XSParticleDecl[2];
+ group.fParticles[0] = (XSParticleDecl)baseType.getParticle();
+ group.fParticles[1] = fParticle;
+ group.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ // the particle to contain the above sequence
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
+ particle.fValue = group;
+ particle.fAnnotations = XSObjectListImpl.EMPTY_LIST;
- fParticle = particle;
- if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
- explicitOpenContent = (XSOpenContentDecl) baseType.getOpenContent();
+ fParticle = particle;
+ if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ explicitOpenContent = (XSOpenContentDecl) baseType.getOpenContent();
+ }
}
}
-
+
// Remove prohibited uses. Must be done before merge for EXTENSION.
fAttrGrp.removeProhibitedAttrs();
try {
@@ -1027,7 +1071,7 @@
if (fDerivedBy == XSConstants.DERIVATION_EXTENSION && baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
- // 1.4.3.2.2.3 One or more of the following is true:
+ // 1.4.3.2.2.3 One or more of the following is true:
// 1.4.3.2.2.3.1 B.{content type}.{open content} (call it BOT) is absent.
// 1.4.3.2.2.3.2 T.{content type}.{open content} (call it EOT) has {mode} interleave.
// 1.4.3.2.2.3.3 Both BOT and EOT have {mode} suffix.
@@ -1037,28 +1081,28 @@
if (baseOpenContent != null && fOpenContent != baseOpenContent) {
// {open content} had a mode of 'none'
if (fOpenContent == null) {
- fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
+ fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
- throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3",
+ throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3",
new Object[]{fName}, complexContent);
}
else {
- // 1.4.3.2.2.3.2
- // 1.4.3.2.2.3.3
+ // 1.4.3.2.2.3.2
+ // 1.4.3.2.2.3.3
if (fOpenContent.fMode == XSOpenContentDecl.MODE_SUFFIX) {
if (baseOpenContent.fMode != XSOpenContentDecl.MODE_SUFFIX) {
- fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
+ fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
- throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3.3",
+ throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3.3",
new Object[]{fName}, complexContent);
}
}
// 1.4.3.2.2.4
if (!baseOpenContent.fWildcard.isSubsetOf(fOpenContent.fWildcard)) {
- fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
+ fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
- throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3.4",
+ throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.3.4",
new Object[]{fName}, complexContent);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org