state.error("Cannot extend a final type", XmlErrorContext.CANNOT_DERIVE_FINAL, parseTree.xgetBase());
// recovery: just keep going
}
// get base content model
SchemaParticle baseContentModel = (baseType == null ? null : baseType.getContentModel());
// TODO: attribute model also
List anonymousTypes = new ArrayList();
Map baseElementModel = extractElementModel(baseType);
Group parseEg = getContentModel(parseTree);
// build extension model
SchemaParticle extensionModel = translateContentModel(
sImpl, parseEg, targetNamespace, chameleon, translateParticleCode(parseEg),
anonymousTypes, baseElementModel, false, null);
// apply rule #2 near http://www.w3.org/TR/xmlschema-1/#c-mve: empty ext model -> mixed taken from base
if (extensionModel == null && !mixed)
mixed = (baseType.getContentType() == SchemaType.MIXED_CONTENT);
// apply Derivation Valid (Extension) rule 1.4.2.2
if (baseType != null && (baseType.getContentType() != SchemaType.EMPTY_CONTENT) &&
((baseType.getContentType() == SchemaType.MIXED_CONTENT) != mixed))
{
state.error("Cannot extend an element-only type with a mixed type or vice-versa", XmlErrorContext.INCONSISTENT_TYPE, parseTree.xgetBase());
// recovery: just keep going
}
// detect the "all" base case
if (baseType != null && baseType.hasAllContent() && extensionModel != null)
{
state.error("Cannot extend a type with 'all' content model", XmlErrorContext.CANNOT_EXTEND_ALL, parseTree.xgetBase());
extensionModel = null; // recovery: drop extension
}
// build content model and anonymous types
SchemaParticle contentModel = extendContentModel(baseContentModel, extensionModel, parseTree);
// detect the nonempty "all" case (empty <all> doesn't count - it needs to be eliminated to match XSD test cases)
boolean isAll = contentModel != null && contentModel.getParticleType() == SchemaParticle.ALL;
// build attr model and anonymous types
SchemaAttributeModelImpl attrModel;
if (baseType == null)
attrModel = new SchemaAttributeModelImpl();