grammar);
// -----------------------------------------------------------------------
// Compose the final content and attribute uses
// -----------------------------------------------------------------------
XSParticleDecl baseContent = baseType.fParticle;
if (typeInfo.fDerivedBy==XSConstants.DERIVATION_RESTRICTION) {
// This is an RESTRICTION
if (typeInfo.fParticle==null && (!(baseContent==null ||
baseContent.emptiable()))) {
throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.2",
new Object[]{typeName}, complexContent);
}
if (typeInfo.fParticle!=null && baseContent==null) {
//REVISIT - need better error msg
throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.3",
new Object[]{typeName}, complexContent);
}
mergeAttributes(baseType.fAttrGrp, typeInfo.fAttrGrp, typeName, false, complexContent);
String error = typeInfo.fAttrGrp.validRestrictionOf(baseType.fAttrGrp);
if (error != null) {
throw new ComplexTypeRecoverableError(error,
new Object[]{typeName}, complexContent);
}
// Remove prohibited uses. Must be done after merge for RESTRICTION.
typeInfo.fAttrGrp.removeProhibitedAttrs();
}
else {
// This is an EXTENSION
//
// Check if the contentType of the base is consistent with the new type
// cos-ct-extends.1.4.2.2
if (baseType.fContentType != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
if (((baseType.fContentType ==
XSComplexTypeDecl.CONTENTTYPE_ELEMENT) &&
mixedContent) ||
((baseType.fContentType ==
XSComplexTypeDecl.CONTENTTYPE_MIXED) && !mixedContent)) {
throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.2.2.2.2.1",
new Object[]{typeName}, complexContent);
}
}
// Create the particle
if (typeInfo.fParticle == null) {
typeInfo.fParticle = baseContent;
}
else if (baseContent==null) {
}
else {
// if the content of either type is an "all" model group, error.
if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
((XSModelGroupImpl)typeInfo.fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL ||
baseType.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
((XSModelGroupImpl)baseType.fParticle.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] = baseType.fParticle;
group.fParticles[1] = typeInfo.fParticle;
// the particle to contain the above sequence
XSParticleDecl particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fValue = group;
typeInfo.fParticle = particle;
}