grammar);
// -----------------------------------------------------------------------
// Compose the final content and attribute uses
// -----------------------------------------------------------------------
XSParticleDecl baseContent = (XSParticleDecl)baseType.getParticle();
if (fDerivedBy==XSConstants.DERIVATION_RESTRICTION) {
// This is an RESTRICTION
// N.B. derivation-ok-restriction.5.2 is checked under schema
// full checking. That's because we need to wait until locals are
// traversed so that occurrence information is correct.
if (fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED &&
baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_MIXED) {
throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.3.1.2",
new Object[]{fName}, complexContent);
}
mergeAttributes(baseType.getAttrGrp(), fAttrGrp, fName, false, complexContent);
if (baseType != SchemaGrammar.fAnyType) {
String error = fAttrGrp.validRestrictionOf(baseType.getAttrGrp());
if (error != null) {
throw new ComplexTypeRecoverableError(error,
new Object[]{fName}, complexContent);
}
}
// Remove prohibited uses. Must be done after merge for RESTRICTION.
fAttrGrp.removeProhibitedAttrs();
}
else {
// This is an EXTENSION
// Create the particle
if (fParticle == null) {
fContentType = baseType.getContentType();
fParticle = baseContent;
}
else if (baseType.getContentType() == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
}
else {
//
// Check if the contentType of the base is consistent with the new type
// cos-ct-extends.1.4.3.2
if (fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT &&
baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_ELEMENT ||
fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED &&
baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_MIXED) {
throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.1",
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) {
throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
null, 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;
// the particle to contain the above sequence
XSParticleDecl particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fValue = group;
fParticle = particle;
}