XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.setBaseTypeName(typeTable.getSimpleSchemaTypeName("java.lang.String"));
simpleType.setContent(restriction);
simpleType.setName(simpleName);
XmlSchemaObjectCollection facets = restriction.getFacets();
EnumType enumType = (EnumType) dataType;
List enumMembers = enumType.getEnumMembers();
for (int i = 0; i < enumMembers.size(); i++) {
facets.add(new XmlSchemaEnumerationFacet(enumMembers.get(i), false));
}
XmlSchemaElement eltOuter = new XmlSchemaElement();
eltOuter.setName(simpleName);
eltOuter.setQName(schemaTypeName);
xmlSchema.getItems().add(eltOuter);
xmlSchema.getElements().add(schemaTypeName, eltOuter);
eltOuter.setSchemaTypeName(simpleType.getQName());
xmlSchema.getItems().add(simpleType);
xmlSchema.getSchemaTypes().add(schemaTypeName, simpleType);
// adding this type to the table
typeTable.addComplexSchema(name, eltOuter.getQName());
} else if (dataType instanceof UnionType) {
XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
XmlSchemaChoice choice = new XmlSchemaChoice();
XmlSchemaObjectCollection items = choice.getItems();
UnionType unionType = (UnionType) dataType;
Member[] members = unionType.getMembers();
for (int i = 0; i < members.length; i++) {
items.add(generateSchemaforFieldsandProperties(xmlSchema, members[i].getDataType(),
members[i].getName(), true));
}
complexType.setParticle(choice);
complexType.setName(simpleName);