Scope unionScope = new Scope(getScope(), identifierNode);
AST discriminatorNode = identifierNode.getNextSibling();
AST caseNode = discriminatorNode.getNextSibling();
// xmlschema:union
XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema);
XmlSchemaSequence sequence = new XmlSchemaSequence();
unionSchemaComplexType.setName(unionScope.toString());
unionSchemaComplexType.setParticle(sequence);
// REVISIT
// TEMPORARILY
// using TypesVisitor to visit <const_type>
// it should be visited by a SwitchTypeSpecVisitor
TypesVisitor visitor = new TypesVisitor(getScope(), schemas, schema, typeMap, null);
visitor.visit(discriminatorNode);
XmlSchemaType stype = visitor.getSchemaType();
CorbaTypeImpl ctype = visitor.getCorbaType();
XmlSchemaElement discriminatorElement = new XmlSchemaElement();
discriminatorElement.setName(discriminator);
discriminatorElement.setSchemaTypeName(stype.getQName());
discriminatorElement.setMinOccurs(1);
discriminatorElement.setMaxOccurs(1);
sequence.getItems().add(discriminatorElement);
XmlSchemaChoice choice = new XmlSchemaChoice();
choice.setMinOccurs(1);
choice.setMaxOccurs(1);
sequence.getItems().add(choice);
// corba:union
Union corbaUnion = new Union();
corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
corbaUnion.setType(unionSchemaComplexType.getQName());
corbaUnion.setDiscriminator(ctype.getQName());
processCaseNodes(caseNode, unionScope, choice, corbaUnion);
// add schemaType