if ((base != null) && (base.length() > 0)) {
XMLType baseType= _schema.getType(base);
if (baseType == null) {
_complexType.setBase(base);
_complexType.setContentType(new SimpleContent(_schema, base));
}
else if (baseType.isSimpleType()) {
String err ="complexType: ";
String name = _complexType.getName();
if (name != null) {
err += name;
} else {
err += "#anonymous-complexType#";
}
err += "A complex type cannot be a restriction"+
" of a simpleType:";
err += baseType.getName();
throw new IllegalStateException(err);
}
//we are now sure that the base is a ComplexType
//but is the base of this complexType a simpleType? (see 4.3.3->simpleContent->content type)
else {
ComplexType temp = (ComplexType) baseType;
if ( ! temp.isSimpleContent() ) {
String err ="complexType: ";
String name = _complexType.getName();
if (name != null) {
err += name;
} else {
err += "#anonymous-complexType#";
}
err += "In a simpleContent when using restriction the base type"+
" must be a complexType whose base is a simpleType.";
throw new IllegalStateException(err);
}
else {
//retrieve the base type of this complexType
//the base type is the complexType but we have to
//work with the simple type of the content type.
SimpleContent contentType = (SimpleContent)temp.getContentType();
_complexType.setBaseType(temp);
_complexType.setBase(temp.getName());
_simpleTypeDef = new SimpleTypeDefinition(_schema, temp.getName(),_id);
SimpleType simpleType = contentType.getSimpleType();
if (simpleType != null) {
_simpleTypeDef.setBaseType(simpleType);
}
else {
_simpleTypeDef.setBaseTypeName(contentType.getTypeName());
}
}
}
}