QName simpleSchemaTypeName = null;
if ( dataType.isDataType() &&
(simpleSchemaTypeName = typeTable.getSimpleSchemaTypeName(dataType.getName()) ) == null )
{
XSDSchema xmlSchema = getXmlSchema(dataType);
XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition();
//set the name
simpleType.setName(dataType.getName());
simpleType.setTargetNamespace(dataType.getURI());
//set abstract=true if abstract
simpleSchemaTypeName = new QName(dataType.getURI(),
dataType.getName(),
(String)targetNamespacePrefixMap.get(dataType.getURI()));
xmlSchema.getContents().add(simpleType);
simpleType.updateElement();
addAnnotations(simpleType, dataType);
if ( !dataType.getBaseTypes().isEmpty() )
{
Type baseType = (Type)dataType.getBaseTypes().get(0);
QName baseSchemaType = null;
try
{
baseSchemaType = buildSchema(baseType);
}
catch ( IllegalArgumentException e )
{
//this means that the base type comes from a original xsd and hence not generated
baseSchemaType = new QName(baseType.getURI(),
baseType.getName(),
generatePrefix());
typeTable.addSimpleSchemaType(baseType.getName(), baseSchemaType);
XSDSimpleTypeDefinition baseTypeDef = xsdFactory.createXSDSimpleTypeDefinition();
baseTypeDef.setName(baseType.getName());
baseTypeDef.setTargetNamespace(baseType.getURI());
typeTable.addXSDTypeDef(baseType.getURI(), baseType.getName(), baseTypeDef);
//include external XSD locations
includeExtXSD(baseType);
}