XmlSchemaObject schemaType)
throws CorbaBindingException {
CorbaUnionHandler obj = null;
try {
XmlSchemaChoice choiceType = (XmlSchemaChoice) schemaType;
Union unionType = (Union) CorbaUtils.getCorbaType(idlType, typeMaps);
QName elName = reader.nextEvent().asStartElement().getName();
obj = new CorbaUnionHandler(elName, idlType, tc, unionType);
// Build the entire union with all branches, etc. Then read info from the XML Event Reader
String branchName = null;
XMLEvent evt = reader.peek();
if (evt.isStartElement()) {
StartElement branchElement = evt.asStartElement();
branchName = branchElement.getName().getLocalPart();
}
List<Unionbranch> branches = unionType.getUnionbranch();
XmlSchemaObjectCollection items = choiceType.getItems();
for (int i = 0; i < branches.size(); i++) {
Unionbranch branch = branches.get(i);
CorbaObjectHandler branchObj = null;
if (branch.getName().equals(branchName)) {
branchObj = readObjectFromStax(reader, branch.getIdltype(), items.getItem(i), true);
// We also need to set the discriminator since this is the branch with the actual
// union value
CorbaObjectHandler discObj =
CorbaHandlerUtils.createTypeHandler(orb,
new QName("discriminator"),
unionType.getDiscriminator(),
typeMaps,
serviceInfo);
obj.setDiscriminator(discObj);
// Determine the value of the discriminator.