Exemple #1
0
  public void visitDeclaredUnion(AST identifierNode) {

    Scope unionScope = new Scope(getScope(), identifierNode);
    AST discriminatorNode = identifierNode.getNextSibling();
    AST caseNode = discriminatorNode.getNextSibling();
    // xmlschema:union
    XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema);
    unionSchemaComplexType.setName(mapper.mapToQName(unionScope));

    // REVISIT
    // TEMPORARILY
    // using TypesVisitor to visit <const_type>
    // it should be visited by a SwitchTypeSpecVisitor
    TypesVisitor visitor = new TypesVisitor(getScope(), definition, schema, wsdlVisitor, null);
    visitor.visit(discriminatorNode);
    CorbaTypeImpl ctype = visitor.getCorbaType();
    Scope fullyQualifiedName = visitor.getFullyQualifiedName();

    XmlSchemaChoice choice = new XmlSchemaChoice();
    choice.setMinOccurs(1);
    choice.setMaxOccurs(1);
    unionSchemaComplexType.setParticle(choice);

    // corba:union
    Union corbaUnion = new Union();
    corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
    corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
    corbaUnion.setType(unionSchemaComplexType.getQName());
    if (ctype != null) {
      corbaUnion.setDiscriminator(ctype.getQName());
    } else {
      // Discriminator type is forward declared.
      UnionDeferredAction unionDiscriminatorAction = new UnionDeferredAction(corbaUnion);
      wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionDiscriminatorAction);
    }

    boolean recursiveAdd = addRecursiveScopedName(identifierNode);

    processCaseNodes(caseNode, unionScope, choice, corbaUnion);

    if (recursiveAdd) {
      removeRecursiveScopedName(identifierNode);
    }

    // add schemaType
    schema.getItems().add(unionSchemaComplexType);
    schema.addType(unionSchemaComplexType);

    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(corbaUnion);

    // REVISIT: are these assignments needed?
    setSchemaType(unionSchemaComplexType);
    setCorbaType(corbaUnion);

    // Need to check if the union was forward declared
    processForwardUnionActions(unionScope);

    // Once we've finished declaring the union, we should make sure it has been removed from
    // the list of scopedNames so that we indicate that is no longer simply forward declared.
    scopedNames.remove(unionScope);
  }