if (content instanceof XmlSchemaComplexContentExtension) {
// to handle extension we need to attach the extended items to the base type
// and create a new type
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
//process the base type if it has not been processed yet
if (!isAlreadyProcessed(extension.getBaseTypeName())) {
//pick the relevant basetype from the schema and process it
XmlSchema resolvedSchema = getParentSchema(parentSchema, extension.getBaseTypeName(), COMPONENT_TYPE);
if (resolvedSchema == null) {
throw new SchemaCompilationException("can not find the compley type " + extension.getBaseTypeName()
+ " from the parent type " + parentSchema.getTargetNamespace());
} else {
XmlSchemaType type = resolvedSchema.getTypeByName(extension.getBaseTypeName());
if (type instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
if (complexType.getName() != null) {
processNamedComplexSchemaType(complexType, resolvedSchema);
} else {
//this is not possible. The extension should always
//have a name
throw new SchemaCompilationException("Unnamed complex type used in extension");//Internationlize this
}
} else if (type instanceof XmlSchemaSimpleType) {
//process simple type
processSimpleSchemaType((XmlSchemaSimpleType) type, null, resolvedSchema, null);
}
}
}
// before actually processing this node, we need to recurse through the base types and add their
// children (sometimes even preserving the order) to the metainfo holder of this type
// the reason is that for extensions, the prefered way is to have the sequences of the base class
//* before * the sequence of the child element.
copyMetaInfoHierarchy(metaInfHolder, extension.getBaseTypeName(), parentSchema);
//process the particle of this node
if (extension.getParticle() != null) {
processParticle(extension.getBaseTypeName(),extension.getParticle(), metaInfHolder, parentSchema);
}
// process attributes
//process attributes - first look for the explicit attributes
processAttributes(extension.getAttributes(),metaInfHolder,parentSchema);
//process any attribute
//somehow the xml schema parser does not seem to pickup the any attribute!!
XmlSchemaAnyAttribute anyAtt = extension.getAnyAttribute();
if (anyAtt != null) {
processAnyAttribute(metaInfHolder, anyAtt);
}
String className = findClassName(extension.getBaseTypeName(), false);
if (!writer.getDefaultClassName().equals(className)) {
//the particle has been processed, However since this is an extension we need to
//add the basetype as an extension to the complex type class.
// The basetype has been processed already