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.
List<CaseType> branchCases = branch.getCase();
String discValue = null;
if (branchCases.size() != 0) {
// This represents a union case. Set the discriminator based on the first
// label value associated with the branch (since we don't have this information)
// from the Stax representation of the Celtix object).
CaseType caseLabel = branchCases.get(0);
discValue = caseLabel.getLabel();
} else {
// This represents the default case.
discValue = obj.createDefaultDiscriminatorLabel();
}
obj.setDiscriminatorValueFromData(discValue);
obj.setValue(branchName, branchObj);
} else {
XmlSchemaElement el = (XmlSchemaElement) items.getItem(i);
QName qname = new QName("", branch.getName());
if (CorbaUtils.isElementFormQualified(serviceInfo, el.getQName().getNamespaceURI())) {
qname = el.getQName();
}
// Create an object holder with no value