private void visitStructMembers( AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) { AST memberTypeNode = identifierNode.getNextSibling(); while (memberTypeNode != null) { AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode); XmlSchemaType schemaType = null; CorbaTypeImpl corbaType = null; Scope fqName = null; try { TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null); visitor.visit(memberTypeNode); schemaType = visitor.getSchemaType(); corbaType = visitor.getCorbaType(); fqName = visitor.getFullyQualifiedName(); } catch (Exception ex) { throw new RuntimeException(ex); } // Handle multiple struct member declarators // <declarators> :== <declarator> { "," <declarator> }* // // A multiple declarator must be an identifier (i.e. of type IDENT) // and cannot be a previous declared (or forward declared) type // (hence the ScopedNameVisitor.accept() call). while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor)) { XmlSchemaType memberSchemaType = schemaType; CorbaTypeImpl memberCorbaType = corbaType; // needed for anonymous arrays in structs if (ArrayVisitor.accept(memberNode)) { Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode)); ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName); arrayVisitor.setSchemaType(schemaType); arrayVisitor.setCorbaType(corbaType); arrayVisitor.visit(memberNode); memberSchemaType = arrayVisitor.getSchemaType(); memberCorbaType = arrayVisitor.getCorbaType(); fqName = arrayVisitor.getFullyQualifiedName(); } XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName); sequence.getItems().add(member); MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName); struct.getMember().add(memberType); memberNode = memberNode.getNextSibling(); } memberTypeNode = memberNode; } }
private void processCaseNodes( AST caseNode, Scope scope, XmlSchemaChoice choice, Union corbaUnion) { while (caseNode != null) { AST typeNode = null; AST nameNode = null; AST labelNode = null; // xmlschema:element XmlSchemaElement element = new XmlSchemaElement(); // corba:unionbranch Unionbranch unionBranch = new Unionbranch(); if (caseNode.getType() == IDLTokenTypes.LITERAL_default) { // default: unionBranch.setDefault(true); typeNode = caseNode.getFirstChild(); nameNode = typeNode.getNextSibling(); } else { // case: createCase(caseNode, unionBranch); labelNode = caseNode.getFirstChild(); if (labelNode.getType() == IDLTokenTypes.LITERAL_case) { labelNode = labelNode.getNextSibling(); } typeNode = labelNode.getNextSibling(); nameNode = typeNode.getNextSibling(); } TypesVisitor visitor = new TypesVisitor(scope, definition, schema, wsdlVisitor, null); visitor.visit(typeNode); XmlSchemaType stype = visitor.getSchemaType(); CorbaTypeImpl ctype = visitor.getCorbaType(); Scope fullyQualifiedName = visitor.getFullyQualifiedName(); // needed for anonymous arrays in unions if (ArrayVisitor.accept(nameNode)) { Scope anonScope = new Scope(scope, TypesUtils.getCorbaTypeNameNode(nameNode)); ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName); arrayVisitor.setSchemaType(stype); arrayVisitor.setCorbaType(ctype); arrayVisitor.visit(nameNode); stype = arrayVisitor.getSchemaType(); ctype = arrayVisitor.getCorbaType(); fullyQualifiedName = visitor.getFullyQualifiedName(); } // xmlschema:element element.setName(nameNode.toString()); if (stype != null) { element.setSchemaTypeName(stype.getQName()); if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { element.setNillable(true); } } else { UnionDeferredAction elementAction = new UnionDeferredAction(element); wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction); } choice.getItems().add(element); // corba:unionbranch unionBranch.setName(nameNode.toString()); if (ctype != null) { unionBranch.setIdltype(ctype.getQName()); } else { // its type is forward declared. UnionDeferredAction unionBranchAction = new UnionDeferredAction(unionBranch); wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction); } corbaUnion.getUnionbranch().add(unionBranch); caseNode = caseNode.getNextSibling(); } }