cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1023402 [6/9] - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/service/model/ common/common/src/main/java/org/apache/cxf/common/xmlschema/ common/common/src/test/java/org/apache/cxf/common/xml...
Date Sun, 17 Oct 2010 02:26:08 GMT
Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java Sun Oct 17 02:26:06 2010
@@ -42,7 +42,7 @@ public class StringVisitor extends Visit
     private AST identifierNode;
     private Scope stringScopedName;
 
-    
+
     public StringVisitor(Scope scope,
                          Definition definition,
                          XmlSchema schemaRef,
@@ -56,7 +56,7 @@ public class StringVisitor extends Visit
     }
 
     public static boolean accept(AST node) {
-        if ((node.getType() == IDLTokenTypes.LITERAL_string) 
+        if ((node.getType() == IDLTokenTypes.LITERAL_string)
             || (node.getType() == IDLTokenTypes.LITERAL_wstring)) {
             return true;
         }
@@ -69,18 +69,18 @@ public class StringVisitor extends Visit
         }
         return true;
     }
-    
+
     public void visit(AST node) {
         // <string_type> ::= "string" "<" <positive_int_const> ">"
         //                 | "string"
         // <wstring_type> ::= "wstring" "<" <positive_int_const> ">"
         //                  | "wstring"
 
-        
+
         stringNode = node;
         boundNode = stringNode.getFirstChild();
 
-        if (identifierNode == null) {    
+        if (identifierNode == null) {
             stringScopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
         } else {
             if (identifierNode.getFirstChild() == null) {
@@ -90,9 +90,9 @@ public class StringVisitor extends Visit
                 Scope anonScope = new Scope(getScope(), identifierNode);
                 stringScopedName = TypesUtils.generateAnonymousScopedName(anonScope, schema);
                 identifierNode = null;
-            } 
+            }
         }
-        
+
         if (boundNode != null
             && !wsdlVisitor.getBoundedStringOverride()) {
             if (identifierNode != null) {
@@ -108,10 +108,10 @@ public class StringVisitor extends Visit
             visitUnboundedString();
         }
     }
-    
+
     private void visitAnonBoundedString() {
         // xmlschema:bounded anon string
-        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true);
         simpleType.setName(stringScopedName.toString());
         XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
         restriction.setBaseTypeName(Constants.XSD_STRING);
@@ -120,9 +120,6 @@ public class StringVisitor extends Visit
         restriction.getFacets().add(maxLengthFacet);
         simpleType.setContent(restriction);
 
-        // add schemaType
-        schema.getItems().add(simpleType);
-        schema.addType(simpleType);
         setSchemaType(simpleType);
 
         CorbaTypeImpl anon = null;
@@ -134,30 +131,30 @@ public class StringVisitor extends Visit
             anonstring.setType(simpleType.getQName());
 
             anon = anonstring;
-            
+
         } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
             // corba:anonwstring
             Anonwstring anonwstring = new Anonwstring();
             anonwstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
             anonwstring.setBound(new Long(boundNode.toString()));
             anonwstring.setType(simpleType.getQName());
-            
+
             anon = anonwstring;
-            
-        } else { 
+
+        } else {
             // should never get here
             throw new RuntimeException("StringVisitor attempted to visit an invalid node");
         }
-        
-        
+
+
         // add corba:anonstring
         typeMap.getStructOrExceptionOrUnion().add(anon);
         setCorbaType(anon);
     }
-    
+
     private void visitBoundedString() {
         // xmlschema:bounded string
-        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, false);
         simpleType.setName(stringScopedName.toString());
         XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
         restriction.setBaseTypeName(Constants.XSD_STRING);
@@ -167,7 +164,7 @@ public class StringVisitor extends Visit
         simpleType.setContent(restriction);
 
         setSchemaType(simpleType);
-                       
+
         Scope anonstringScopedName = new Scope(getScope(), "_Anon1_" + stringScopedName.tail());
         String anonstringName = anonstringScopedName.toString();
         CorbaTypeImpl anon = null;
@@ -179,21 +176,21 @@ public class StringVisitor extends Visit
             anonstring.setType(simpleType.getQName());
 
             anon = anonstring;
-            
+
         } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
             // corba:anonwstring
             Anonwstring anonwstring = new Anonwstring();
             anonwstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
             anonwstring.setBound(new Long(boundNode.toString()));
             anonwstring.setType(simpleType.getQName());
-            
+
             anon = anonwstring;
-            
-        } else { 
+
+        } else {
             // should never get here
             throw new RuntimeException("StringVisitor attempted to visit an invalid node");
         }
-        
+
         // add corba:anonstring
         typeMap.getStructOrExceptionOrUnion().add(anon);
 
@@ -207,12 +204,12 @@ public class StringVisitor extends Visit
         // add corba:alias
         setCorbaType(alias);
     }
-    
+
     private void visitUnboundedString() {
         // schema type
         setSchemaType(schemas.getTypeByQName(Constants.XSD_STRING));
 
-        
+
         // corba type
         CorbaTypeImpl corbaString = new CorbaTypeImpl();
         if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
@@ -221,7 +218,7 @@ public class StringVisitor extends Visit
         } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
             corbaString.setQName(CorbaConstants.NT_CORBA_WSTRING);
             corbaString.setName(CorbaConstants.NT_CORBA_WSTRING.getLocalPart());
-        } else { 
+        } else {
             // should never get here
             throw new RuntimeException("StringVisitor attempted to visit an invalid node");
         }
@@ -229,5 +226,5 @@ public class StringVisitor extends Visit
 
         setCorbaType(corbaString);
     }
-    
+
 }

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java Sun Oct 17 02:26:06 2010
@@ -38,7 +38,7 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 public class StructVisitor extends VisitorBase {
-    
+
     public StructVisitor(Scope scope,
                          Definition defn,
                          XmlSchema schemaRef,
@@ -52,7 +52,7 @@ public class StructVisitor extends Visit
         }
         return false;
     }
-    
+
     public void visit(AST node) {
         // <struct_type> ::= "struct" <identifier> "{" <member_list> "}"
         // <member_list> ::= <member>+
@@ -66,16 +66,16 @@ public class StructVisitor extends Visit
             visitDeclaredStruct(identifierNode);
         }
     }
-        
+
     public void visitDeclaredStruct(AST identifierNode) {
-        Scope structScope = new Scope(getScope(), identifierNode);        
+        Scope structScope = new Scope(getScope(), identifierNode);
 
         // xmlschema:struct
-        XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema);
+        XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
         complexType.setName(mapper.mapToQName(structScope));
         XmlSchemaSequence sequence = new XmlSchemaSequence();
         complexType.setParticle(sequence);
-        
+
         // corba:struct
         Struct struct = new Struct();
         struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
@@ -85,22 +85,19 @@ public class StructVisitor extends Visit
         boolean recursiveAdd = addRecursiveScopedName(identifierNode);
 
         // struct members
-        visitStructMembers(identifierNode, struct, sequence, structScope);        
-        
+        visitStructMembers(identifierNode, struct, sequence, structScope);
+
         if (recursiveAdd) {
             removeRecursiveScopedName(identifierNode);
         }
-        // add schemaType
-        schema.getItems().add(complexType);
-        schema.addType(complexType);
 
         // add corbaType
         typeMap.getStructOrExceptionOrUnion().add(struct);
-        
+
         // REVISIT: are there assignment needed?
         setSchemaType(complexType);
         setCorbaType(struct);
-        
+
         // Need to check if the struct was forward declared
         processForwardStructActions(structScope);
 
@@ -108,14 +105,14 @@ public class StructVisitor extends Visit
         // the list of scopedNames so that we inidicate that is no longer simply forward declared.
         scopedNames.remove(structScope);
     }
-    
+
     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;
@@ -125,10 +122,10 @@ public class StructVisitor extends Visit
                                                         schema,
                                                         wsdlVisitor,
                                                         null);
-                visitor.visit(memberTypeNode);                
+                visitor.visit(memberTypeNode);
                 schemaType = visitor.getSchemaType();
                 corbaType = visitor.getCorbaType();
-                fqName = visitor.getFullyQualifiedName();                
+                fqName = visitor.getFullyQualifiedName();
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
             }
@@ -145,7 +142,7 @@ public class StructVisitor extends Visit
 
                 XmlSchemaType memberSchemaType = schemaType;
                 CorbaTypeImpl memberCorbaType = corbaType;
-                // needed for anonymous arrays in structs 
+                // needed for anonymous arrays in structs
                 if (ArrayVisitor.accept(memberNode)) {
                     Scope anonScope = new Scope(structScope,
                                                 TypesUtils.getCorbaTypeNameNode(memberTypeNode));
@@ -163,25 +160,25 @@ public class StructVisitor extends Visit
                     fqName = arrayVisitor.getFullyQualifiedName();
                 }
 
-                XmlSchemaElement member = 
+                XmlSchemaElement member =
                     createXmlSchemaElement(memberNode, memberSchemaType, fqName);
-                sequence.getItems().add(member);           
-                MemberType memberType = 
-                    createMemberType(memberNode, memberCorbaType, fqName);            
+                sequence.getItems().add(member);
+                MemberType memberType =
+                    createMemberType(memberNode, memberCorbaType, fqName);
                 struct.getMember().add(memberType);
-                
+
                 memberNode = memberNode.getNextSibling();
             }
-            
+
             memberTypeNode = memberNode;
         }
     }
-    
-    private XmlSchemaElement createXmlSchemaElement(AST memberNode, 
+
+    private XmlSchemaElement createXmlSchemaElement(AST memberNode,
                                                     XmlSchemaType schemaType,
                                                     Scope fqName) {
         // xmlschema:member
-        XmlSchemaElement member = new XmlSchemaElement();
+        XmlSchemaElement member = new XmlSchemaElement(schema, false);
         String memberName = memberNode.toString();
         member.setName(memberName);
         member.setSchemaType(schemaType);
@@ -196,7 +193,7 @@ public class StructVisitor extends Visit
         }
         return member;
     }
-    
+
     private MemberType createMemberType(AST memberNode,
                                         CorbaTypeImpl corbaType,
                                         Scope fqName) {
@@ -204,25 +201,25 @@ public class StructVisitor extends Visit
         String memberName = memberNode.toString();
         MemberType memberType = new MemberType();
         memberType.setName(memberName);
-        if (corbaType != null) {                            
+        if (corbaType != null) {
             memberType.setIdltype(corbaType.getQName());
         } else {
             wsdlVisitor.getDeferredActions().
-                add(fqName, new StructDeferredAction(memberType)); 
+                add(fqName, new StructDeferredAction(memberType));
         }
         return memberType;
     }
-    
+
     private void visitForwardDeclaredStruct(AST identifierNode) {
-        String structName = identifierNode.toString();        
+        String structName = identifierNode.toString();
         Scope structScope = new Scope(getScope(), structName);
-        
+
         ScopeNameCollection scopedNames = wsdlVisitor.getScopedNames();
         if (scopedNames.getScope(structScope) == null) {
             scopedNames.add(structScope);
-        }        
+        }
     }
- 
+
     // Process any actions that were defered for a forward declared struct
     private void processForwardStructActions(Scope structScope) {
         if (wsdlVisitor.getDeferredActions() != null) {
@@ -231,24 +228,24 @@ public class StructVisitor extends Visit
             if ((list != null) && !list.isEmpty()) {
                 XmlSchemaType stype = getSchemaType();
                 CorbaTypeImpl ctype = getCorbaType();
-                Iterator iterator = list.iterator();                    
+                Iterator iterator = list.iterator();
                 while (iterator.hasNext()) {
                     SchemaDeferredAction action = (SchemaDeferredAction)iterator.next();
-                    action.execute(stype, ctype);                       
+                    action.execute(stype, ctype);
                 }
-                iterator = list.iterator();                    
+                iterator = list.iterator();
                 while (iterator.hasNext()) {
                     iterator.next();
-                    iterator.remove();                       
-                }                                          
-            }            
-        }   
+                    iterator.remove();
+                }
+            }
+        }
     }
 
     private boolean addRecursiveScopedName(AST identifierNode) {
-        String structName = identifierNode.toString();        
+        String structName = identifierNode.toString();
         Scope structScope = new Scope(getScope(), structName);
-        
+
         ScopeNameCollection scopedNames = wsdlVisitor.getScopedNames();
         if (scopedNames.getScope(structScope) == null) {
             scopedNames.add(structScope);
@@ -258,9 +255,9 @@ public class StructVisitor extends Visit
     }
 
     private void removeRecursiveScopedName(AST identifierNode) {
-        String structName = identifierNode.toString();        
+        String structName = identifierNode.toString();
         Scope structScope = new Scope(getScope(), structName);
-        
+
         ScopeNameCollection scopedNames = wsdlVisitor.getScopedNames();
         scopedNames.remove(structScope);
     }

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java Sun Oct 17 02:26:06 2010
@@ -46,14 +46,14 @@ public class UnionVisitor extends Visito
                         WSDLASTVisitor wsdlVisitor) {
         super(scope, defn, schemaRef, wsdlVisitor);
     }
-    
+
     public static boolean accept(AST node) {
         if (node.getType() == IDLTokenTypes.LITERAL_union) {
             return true;
         }
         return false;
     }
-    
+
     public void visit(AST unionNode) {
         // <union_type> ::= "union" <identifier> "switch" "(" <switch_type_spec> ")"
         //                  "{" <switch_body> "}"
@@ -67,8 +67,8 @@ public class UnionVisitor extends Visito
         // <case_label> ::= "case" <const_expr> ":"
         //                | "default" ":"
         // <element_spec> ::= <type_spec> <declarator>
-        
-        
+
+
         AST identifierNode = unionNode.getFirstChild();
         // Check if its a forward declaration
         if (identifierNode.getFirstChild() == null && identifierNode.getNextSibling() == null) {
@@ -77,31 +77,31 @@ public class UnionVisitor extends Visito
             visitDeclaredUnion(identifierNode);
         }
     }
-    
-    public void visitDeclaredUnion(AST identifierNode) {        
-        
+
+    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);
+        XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema, true);
         unionSchemaComplexType.setName(mapper.mapToQName(unionScope));
-        
+
         // REVISIT
-        // TEMPORARILY 
+        // 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()));
@@ -111,11 +111,11 @@ public class UnionVisitor extends Visito
             corbaUnion.setDiscriminator(ctype.getQName());
         } else {
             // Discriminator type is forward declared.
-            UnionDeferredAction unionDiscriminatorAction = 
+            UnionDeferredAction unionDiscriminatorAction =
                 new UnionDeferredAction(corbaUnion);
             wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionDiscriminatorAction);
         }
-       
+
         boolean recursiveAdd = addRecursiveScopedName(identifierNode);
 
         processCaseNodes(caseNode, unionScope, choice, corbaUnion);
@@ -124,17 +124,13 @@ public class UnionVisitor extends Visito
             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);
 
@@ -142,7 +138,7 @@ public class UnionVisitor extends Visito
         // the list of scopedNames so that we indicate that is no longer simply forward declared.
         scopedNames.remove(unionScope);
     }
-    
+
     private void processCaseNodes(AST caseNode,
                                   Scope scope,
                                   XmlSchemaChoice choice,
@@ -151,9 +147,9 @@ public class UnionVisitor extends Visito
             AST typeNode  = null;
             AST nameNode  = null;
             AST labelNode = null;
-            
+
             // xmlschema:element
-            XmlSchemaElement element = new XmlSchemaElement();
+            XmlSchemaElement element = new XmlSchemaElement(schema, false);
 
             // corba:unionbranch
             Unionbranch unionBranch = new Unionbranch();
@@ -161,22 +157,22 @@ public class UnionVisitor extends Visito
             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,
@@ -187,8 +183,8 @@ public class UnionVisitor extends Visito
             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));
@@ -205,8 +201,8 @@ public class UnionVisitor extends Visito
                 ctype = arrayVisitor.getCorbaType();
                 fullyQualifiedName = visitor.getFullyQualifiedName();
             }
-            
-            
+
+
             // xmlschema:element
             element.setName(nameNode.toString());
             if (stype != null) {
@@ -215,29 +211,29 @@ public class UnionVisitor extends Visito
                     element.setNillable(true);
                 }
             } else {
-                UnionDeferredAction elementAction = 
+                UnionDeferredAction elementAction =
                     new UnionDeferredAction(element);
-                wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction); 
+                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 = 
+                UnionDeferredAction unionBranchAction =
                     new UnionDeferredAction(unionBranch);
-                wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction); 
+                wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction);
             }
             corbaUnion.getUnionbranch().add(unionBranch);
-            
+
             caseNode = caseNode.getNextSibling();
         }
     }
-    
+
     private void createCase(AST caseNode, Unionbranch unionBranch) {
         AST node = caseNode.getFirstChild();
         if (node != null) {
@@ -246,7 +242,7 @@ public class UnionVisitor extends Visito
                 CaseType caseType = new CaseType();
                 caseType.setLabel(node.getNextSibling().toString());
                 unionBranch.getCase().add(caseType);
-                
+
                 // recursive call
                 createCase(node, unionBranch);
             } else {
@@ -257,17 +253,17 @@ public class UnionVisitor extends Visito
             }
         }
     }
-    
+
     private void visitForwardDeclaredUnion(AST identifierNode) {
-        String unionName = identifierNode.toString();        
+        String unionName = identifierNode.toString();
         Scope unionScope = new Scope(getScope(), unionName);
-        
+
         ScopeNameCollection scopedNames = wsdlVisitor.getScopedNames();
         if (scopedNames.getScope(unionScope) == null) {
             scopedNames.add(unionScope);
-        }        
+        }
     }
- 
+
     // Process any actions that were defered for a forward declared union
     private void processForwardUnionActions(Scope unionScope) {
         if (wsdlVisitor.getDeferredActions() != null) {
@@ -276,18 +272,18 @@ public class UnionVisitor extends Visito
             if ((list != null) && !list.isEmpty()) {
                 XmlSchemaType stype = getSchemaType();
                 CorbaTypeImpl ctype = getCorbaType();
-                Iterator iterator = list.iterator();                    
+                Iterator iterator = list.iterator();
                 while (iterator.hasNext()) {
                     SchemaDeferredAction action = (SchemaDeferredAction)iterator.next();
-                    action.execute(stype, ctype);                       
+                    action.execute(stype, ctype);
                 }
-                iterator = list.iterator();                    
+                iterator = list.iterator();
                 while (iterator.hasNext()) {
                     iterator.next();
-                    iterator.remove();                       
-                }                                          
-            }            
-        }   
+                    iterator.remove();
+                }
+            }
+        }
     }
 
     private boolean addRecursiveScopedName(AST identifierNode) {

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java Sun Oct 17 02:26:06 2010
@@ -53,10 +53,10 @@ import org.apache.ws.commons.schema.cons
 
 public final class WSDLASTVisitor implements ASTVisitor {
 
-    Definition definition;    
+    Definition definition;
     XmlSchema schema;
     XmlSchemaCollection schemas;
-    
+
     TypeMappingType typeMap;
     ScopeNameCollection scopedNames;
     ScopeNameCollection recursionList;
@@ -67,21 +67,21 @@ public final class WSDLASTVisitor implem
 
     private XmlSchemaType sequenceOctetType;
     private boolean boundedStringOverride;
-    private String idlFile;    
+    private String idlFile;
     private String outputDir;
-    private String importSchemaFilename; 
+    private String importSchemaFilename;
     private boolean schemaGenerated;
-    private ModuleToNSMapper moduleToNSMapper;    
+    private ModuleToNSMapper moduleToNSMapper;
     private WSDLSchemaManager manager;
     private Map<Scope, List<Scope>> inheritScopeMap;
 
     public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns)
         throws WSDLException, JAXBException {
-        
+
         manager = new WSDLSchemaManager();
 
         definition = manager.createWSDLDefinition(tns);
-        
+
         inheritScopeMap = new TreeMap<Scope, List<Scope>>();
 
         targetNamespace = tns;
@@ -94,14 +94,14 @@ public final class WSDLASTVisitor implem
         }
         schema = manager.createXmlSchemaForDefinition(definition, schemans, schemas);
         declaredWSAImport = false;
-        
+
         addAnyType();
-        
+
         typeMap = manager.createCorbaTypeMap(definition, corbatypemaptns);
-        
+
         // idl:sequence<octet> maps to xsd:base64Binary by default
         sequenceOctetType = schemas.getTypeByQName(Constants.XSD_BASE64);
-        
+
         // treat bounded corba:string/corba:wstring as unbounded if set to true
         setBoundedStringOverride(false);
 
@@ -120,62 +120,62 @@ public final class WSDLASTVisitor implem
             definitionVisitor.visit(node);
             node = node.getNextSibling();
         }
-        
-        try {           
-            manager.attachSchemaToWSDL(definition, schema, isSchemaGenerated());            
+
+        try {
+            manager.attachSchemaToWSDL(definition, schema, isSchemaGenerated());
         } catch (Exception ex) {
             throw new RuntimeException(ex);
         }
     }
-    
+
     public void setSchemaGenerated(boolean value) {
         schemaGenerated = value;
     }
-    
+
     public boolean isSchemaGenerated() {
         return schemaGenerated;
     }
-    
+
     public void updateSchemaNamespace(String name) throws Exception  {
-        schema.setTargetNamespace(name);                   
+        schema.setTargetNamespace(name);
     }
-    
+
     public void setQualified(boolean qualified) throws Exception  {
         if (qualified) {
-            XmlSchemaForm form = new XmlSchemaForm("qualified");            
+            XmlSchemaForm form = XmlSchemaForm.QUALIFIED;
             schema.setAttributeFormDefault(form);
             schema.setElementFormDefault(form);
-        }                          
+        }
     }
-    
-    public void setSupportPolymorphicFactories(boolean support) throws Exception  {               
-        supportPolymorphicFactories = support;                      
+
+    public void setSupportPolymorphicFactories(boolean support) throws Exception  {
+        supportPolymorphicFactories = support;
     }
-      
+
     public boolean getSupportPolymorphicFactories() {
         return supportPolymorphicFactories;
     }
-    
+
     public void setIdlFile(String idl) {
         idlFile = idl;
     }
-    
+
     public String getIdlFile() {
         return idlFile;
     }
-    
+
     public Map<Scope, List<Scope>> getInheritedScopeMap() {
         return inheritScopeMap;
     }
-    
+
     public void setOutputDir(String outDir) {
         outputDir = outDir;
     }
-    
+
     public String getOutputDir() {
         return outputDir;
     }
-    
+
     public Definition getDefinition() {
         return definition;
     }
@@ -187,11 +187,11 @@ public final class WSDLASTVisitor implem
     public XmlSchema getSchema() {
         return schema;
     }
-    
+
     public XmlSchemaCollection getSchemas() {
         return schemas;
     }
-    
+
     public ScopeNameCollection getScopedNames() {
         return scopedNames;
     }
@@ -203,23 +203,23 @@ public final class WSDLASTVisitor implem
     public DeferredActionCollection getDeferredActions() {
         return deferredActions;
     }
-    
+
     public TypeMappingType getTypeMap() {
         return typeMap;
     }
-    
+
     public XmlSchemaType getSequenceOctetType() {
         return sequenceOctetType;
     }
-    
-    public void setImportSchema(String filename) {        
+
+    public void setImportSchema(String filename) {
         importSchemaFilename = filename;
     }
-    
+
     public String getImportSchemaFilename() {
         return importSchemaFilename;
-    }        
-    
+    }
+
     public void setSequenceOctetType(String type) throws Exception {
         XmlSchemaType stype = null;
         if (type.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY)) {
@@ -227,20 +227,20 @@ public final class WSDLASTVisitor implem
         } else if (type.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY)) {
             stype = schemas.getTypeByQName(Constants.XSD_HEXBIN);
         } else {
-            throw new ToolException("WSDLASTVisitor: Invalid XmlSchemaType specified " 
+            throw new ToolException("WSDLASTVisitor: Invalid XmlSchemaType specified "
                                     + "for idl:sequence<octet> mapping.");
         }
         sequenceOctetType = stype;
     }
-    
+
     public boolean getBoundedStringOverride() {
         return boundedStringOverride;
     }
-    
+
     public void setBoundedStringOverride(boolean value) {
         boundedStringOverride = value;
     }
-    
+
     public Binding[] getCorbaBindings() {
         List<Binding> result = new ArrayList<Binding>();
         Map bindings = definition.getBindings();
@@ -259,20 +259,20 @@ public final class WSDLASTVisitor implem
         return (Binding[]) result.toArray(new Binding[result.size()]);
     }
 
-    public boolean writeDefinition(Writer writer) throws Exception {        
+    public boolean writeDefinition(Writer writer) throws Exception {
         writeDefinition(definition, writer);
         return true;
     }
-    
-    public boolean writeDefinition(Definition def, Writer writer) throws Exception {       
+
+    public boolean writeDefinition(Definition def, Writer writer) throws Exception {
         WSDLUtils.writeWSDL(def, writer);
         return true;
     }
-    
+
     public boolean writeSchemaDefinition(Definition definit, Writer writer) throws Exception  {
         Definition def = manager.createWSDLDefinition(targetNamespace + "-types");
-        def.createTypes();        
-        def.setTypes(definit.getTypes());                       
+        def.createTypes();
+        def.setTypes(definit.getTypes());
         WSDLUtils.writeSchema(def, writer);
         return true;
     }
@@ -286,95 +286,95 @@ public final class WSDLASTVisitor implem
         writeSchemaDefinition(defn, writer);
         return true;
     }
-    
-    // REVISIT - When CXF corrects the wsdlValidator - will switch back on the 
+
+    // REVISIT - When CXF corrects the wsdlValidator - will switch back on the
     // validation of the generated wsdls.
     public boolean writeDefinitions(Writer writer, Writer schemaWriter,
-                                    Writer logicalWriter, Writer physicalWriter, 
-                                    String schemaFilename, String logicalFile, 
+                                    Writer logicalWriter, Writer physicalWriter,
+                                    String schemaFilename, String logicalFile,
                                     String physicalFile) throws Exception {
-                        
+
         Definition logicalDef = getLogicalDefinition(schemaFilename, schemaWriter);
         Definition physicalDef = null;
         // schema only
-        if ((schemaFilename != null || importSchemaFilename != null) 
+        if ((schemaFilename != null || importSchemaFilename != null)
             && (logicalFile == null && physicalFile == null)) {
             physicalDef = getPhysicalDefinition(logicalDef, true);
         } else {
             physicalDef = getPhysicalDefinition(logicalDef, false);
-        }                
-        
+        }
+
         // write out logical file -L and physical in default
         if (logicalFile != null && physicalFile == null) {
-            writeDefinition(logicalDef, logicalWriter);            
+            writeDefinition(logicalDef, logicalWriter);
             manager.addWSDLDefinitionImport(physicalDef,
                                             logicalDef,
                                             "logicaltns",
                                             logicalFile);
             writeDefinition(physicalDef, writer);
         } else if (logicalFile != null && physicalFile != null) {
-            // write both logical -L and physical files -P           
+            // write both logical -L and physical files -P
             writeDefinition(logicalDef, logicalWriter);
             manager.addWSDLDefinitionImport(physicalDef,
                                             logicalDef,
                                             "logicaltns",
                                             logicalFile);
-            writeDefinition(physicalDef, physicalWriter);            
+            writeDefinition(physicalDef, physicalWriter);
         } else if (logicalFile == null && physicalFile != null) {
             // write pyhsical file -P and logical in default
-            writeDefinition(logicalDef, writer);            
+            writeDefinition(logicalDef, writer);
             manager.addWSDLDefinitionImport(physicalDef,
                                             logicalDef,
                                             "logicaltns",
-                                            getIdlFile());            
-            writeDefinition(physicalDef, physicalWriter);            
+                                            getIdlFile());
+            writeDefinition(physicalDef, physicalWriter);
         } else if ((logicalFile == null && physicalFile == null)
-            && (schemaFilename != null || importSchemaFilename != null)) {           
+            && (schemaFilename != null || importSchemaFilename != null)) {
             // write out the schema file -T and default of logical
             // and physical together.
-            writeDefinition(physicalDef, writer);               
+            writeDefinition(physicalDef, writer);
         } else if (logicalFile == null && physicalFile == null
             && schemaFilename == null) {
-            writeDefinition(definition, writer);            
-        }        
-      
+            writeDefinition(definition, writer);
+        }
+
         return true;
-    }    
-    
-    // Gets the logical definition for a file - an import will be added for the 
+    }
+
+    // Gets the logical definition for a file - an import will be added for the
     // schema types if -T is used and a separate schema file generated.
     // if -n is used an import will be added for the schema types and no types generated.
-    private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter) 
-        throws WSDLException, JAXBException, Exception {        
+    private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter)
+        throws WSDLException, JAXBException, Exception {
         Definition def = manager.createWSDLDefinition(targetNamespace);
 
         // checks for -T option.
         if (schemaFilename != null) {
-            writeSchemaDefinition(definition, schemaWriter);            
+            writeSchemaDefinition(definition, schemaWriter);
             manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), schemaFilename);
         } else {
             // checks for -n option
-            if (importSchemaFilename == null) {                
+            if (importSchemaFilename == null) {
                 Types types = definition.getTypes();
                 def.setTypes(types);
-            } else {                
+            } else {
                 manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), importSchemaFilename);
             }
-        }            
-        
+        }
+
         Iterator iter = definition.getAllPortTypes().values().iterator();
         while (iter.hasNext()) {
             PortType port = (PortType)iter.next();
             def.addPortType(port);
         }
-        
+
         iter = definition.getMessages().values().iterator();
         while (iter.hasNext()) {
             Message msg = (Message)iter.next();
             def.addMessage(msg);
-        }                
-        
-        iter = definition.getNamespaces().values().iterator();       
+        }
+
+        iter = definition.getNamespaces().values().iterator();
         while (iter.hasNext()) {
             String namespace = (String)iter.next();
             String prefix = definition.getPrefix(namespace);
@@ -384,37 +384,37 @@ public final class WSDLASTVisitor implem
                 def.removeNamespace(prefix);
             }
         }
-        
-        iter = definition.getImports().values().iterator();       
+
+        iter = definition.getImports().values().iterator();
         while (iter.hasNext()) {
             Import importType = (Import)iter.next();
-            def.addImport(importType);            
+            def.addImport(importType);
         }
-        
+
         def.setDocumentationElement(definition.getDocumentationElement());
         def.setDocumentBaseURI(definition.getDocumentBaseURI());
-        
+
         return def;
     }
-    
+
     // Write the physical definitions to a file.
-    private Definition getPhysicalDefinition(Definition logicalDef, boolean schemaOnly) 
+    private Definition getPhysicalDefinition(Definition logicalDef, boolean schemaOnly)
         throws WSDLException, JAXBException {
-        
-        Definition def = null;        
+
+        Definition def = null;
         if (schemaOnly) {
             def = logicalDef;
         } else {
             def = manager.createWSDLDefinition(targetNamespace);
         }
-                
-        Iterator iter = definition.getNamespaces().values().iterator();       
+
+        Iterator iter = definition.getNamespaces().values().iterator();
         while (iter.hasNext()) {
             String namespace = (String)iter.next();
             String prefix = definition.getPrefix(namespace);
-            def.addNamespace(prefix, namespace); 
+            def.addNamespace(prefix, namespace);
         }
-        
+
         iter = definition.getAllBindings().values().iterator();
         while (iter.hasNext()) {
             Binding binding = (Binding)iter.next();
@@ -422,20 +422,20 @@ public final class WSDLASTVisitor implem
         }
         iter = definition.getAllServices().values().iterator();
         while (iter.hasNext()) {
-            Service service = (Service)iter.next(); 
+            Service service = (Service)iter.next();
             def.addService(service);
         }
         iter = definition.getExtensibilityElements().iterator();
         while (iter.hasNext()) {
             ExtensibilityElement ext = (ExtensibilityElement)iter.next();
             def.addExtensibilityElement(ext);
-        }                
-        
+        }
+
         def.setExtensionRegistry(definition.getExtensionRegistry());
-                
+
         return def;
     }
-    
+
     /**
      * Older versions of XmlSchema forgot to include anyType in the schema.
      */
@@ -448,21 +448,21 @@ public final class WSDLASTVisitor implem
         if (schemaList != null) {
             for (int i = 0; i < schemaList.length; i++) {
                 if (schemaList[i].getTargetNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                    XmlSchemaType anyType = new XmlSchemaType(schemaList[i]);
+                    XmlSchemaType anyType = new XmlSchemaType(schemaList[i], false) { };
                     anyType.setName(Constants.XSD_ANYTYPE.getLocalPart());
                     schemaList[i].addType(anyType);
                     break;
                 }
             }
         }
-    }       
-    
+    }
+
     public boolean getDeclaredWSAImport() {
         return declaredWSAImport;
     }
-    
+
     public void setDeclaredWSAImport(boolean declaredImport) {
-        declaredWSAImport = declaredImport;        
+        declaredWSAImport = declaredImport;
     }
 
     public void setModuleToNSMapping(Map<String, String> map) {

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLSchemaManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLSchemaManager.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLSchemaManager.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLSchemaManager.java Sun Oct 17 02:26:06 2010
@@ -46,13 +46,11 @@ import org.apache.cxf.binding.corba.wsdl
 import org.apache.cxf.binding.corba.wsdl.OperationType;
 import org.apache.cxf.binding.corba.wsdl.TypeMappingType;
 import org.apache.cxf.common.WSDLConstants;
-import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.wsdl.JAXBExtensionHelper;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
 import org.apache.ws.commons.schema.XmlSchemaImport;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
 import org.apache.ws.commons.schema.constants.Constants;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 
@@ -72,22 +70,22 @@ public class WSDLSchemaManager {
         XmlSchema schema;
         boolean isGenerated;
     }
-    
+
     List<DeferredSchemaAttachment> deferredAttachments;
-    
+
     public WSDLSchemaManager() {
         defns = new HashMap<String, Definition>();
         schemas = new HashMap<String, XmlSchema>();
         importedDefns = new HashMap<File, Definition>();
-        importedSchemas = new HashMap<File, XmlSchema>();     
+        importedSchemas = new HashMap<File, XmlSchema>();
         defnSchemas = new HashMap<String, XmlSchema>();
-        
+
         deferredAttachments = new ArrayList<DeferredSchemaAttachment>();
     }
 
     public Definition createWSDLDefinition(String tns) throws WSDLException, JAXBException {
         WSDLFactory wsdlFactory = WSDLFactory.newInstance();
-        Definition wsdlDefinition = wsdlFactory.newDefinition();        
+        Definition wsdlDefinition = wsdlFactory.newDefinition();
         wsdlDefinition.setTargetNamespace(tns);
         wsdlDefinition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
         wsdlDefinition.addNamespace(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
@@ -116,9 +114,8 @@ public class WSDLSchemaManager {
         schemas.put(schemans, xmlSchema);
         return xmlSchema;
     }
-    
-    public XmlSchema createXmlSchemaForDefinition(Definition defn,
-                                                  String schemans,
+
+    public XmlSchema createXmlSchemaForDefinition(Definition defn, String schemans,
                                                   XmlSchemaCollection schemaCol) {
         XmlSchema xmlSchema = createXmlSchema(schemans, schemaCol);
         defnSchemas.put(schemans, xmlSchema);
@@ -134,11 +131,9 @@ public class WSDLSchemaManager {
             defn.addNamespace(prefix, ns);
         }
     }
-    
-    public void addWSDLDefinitionImport(Definition rootDefn,
-                                        Definition defn,
-                                        String prefix,
-                                        String fileName) {
+
+    public void addWSDLDefinitionImport(Definition rootDefn, Definition defn,
+                                        String prefix, String fileName) {
         if (!fileName.endsWith(".wsdl")) {
             fileName = fileName + ".wsdl";
         }
@@ -146,14 +141,10 @@ public class WSDLSchemaManager {
         addWSDLDefinitionImport(rootDefn, defn, prefix, file);
     }
 
-    public void addWSDLDefinitionImport(Definition rootDefn,
-                                        Definition defn,
-                                        String prefix,
-                                        File file) {
-        if (rootDefn.getImports().get(defn.getTargetNamespace()) == null 
-            && !file.getName().equals(".wsdl")) {
-            // Only import if not already done to prevent multiple imports of the same file 
-            // in the WSDL.  Also watch out for empty fileNames, which by this point in the
+    public void addWSDLDefinitionImport(Definition rootDefn, Definition defn, String prefix, File file) {
+        if (rootDefn.getImports().get(defn.getTargetNamespace()) == null && !file.getName().equals(".wsdl")) {
+            // Only import if not already done to prevent multiple imports of the same file
+            // in the WSDL. Also watch out for empty fileNames, which by this point in the
             // code would show up as ".wsdl".
             Import importDefn = rootDefn.createImport();
             if (!ignoreImports) {
@@ -184,10 +175,9 @@ public class WSDLSchemaManager {
         // Make sure we haven't already imported the schema.
         String importNamespace = schema.getTargetNamespace();
         boolean included = false;
-        for (Iterator i = rootSchema.getIncludes().getIterator(); i.hasNext();) {
-            Object o = i.next();
-            if (o instanceof XmlSchemaImport) {
-                XmlSchemaImport imp = (XmlSchemaImport)o;
+        for (XmlSchemaExternal ext : rootSchema.getExternals()) {
+            if (ext instanceof XmlSchemaImport) {
+                XmlSchemaImport imp = (XmlSchemaImport)ext;
                 if (imp.getNamespace().equals(importNamespace)) {
                     included = true;
                     break;
@@ -196,13 +186,11 @@ public class WSDLSchemaManager {
         }
 
         if (!included) {
-            XmlSchemaImport importSchema = new XmlSchemaImport();
+            XmlSchemaImport importSchema = new XmlSchemaImport(rootSchema);
             if (!ignoreImports) {
                 importSchema.setSchemaLocation(file.toURI().toString());
             }
             importSchema.setNamespace(schema.getTargetNamespace());
-            rootSchema.getItems().add(importSchema);
-            rootSchema.getIncludes().add(importSchema);
         }
         if (!importedSchemas.containsKey(file)) {
             importedSchemas.put(file, schema);
@@ -219,16 +207,14 @@ public class WSDLSchemaManager {
     }
 
     public void addWSDLSchemaImport(Definition def, String tns, File file) throws Exception {
-        //REVISIT, check if the wsdl schema already exists.
+        // REVISIT, check if the wsdl schema already exists.
         Types types = def.getTypes();
         if (types == null) {
             types = def.createTypes();
-            def.setTypes(types);            
+            def.setTypes(types);
         }
-        Schema wsdlSchema = (Schema) 
-            def.getExtensionRegistry().createExtension(Types.class,
-                                                       new QName(Constants.URI_2001_SCHEMA_XSD,
-                                                                 "schema"));
+        Schema wsdlSchema = (Schema)def.getExtensionRegistry()
+            .createExtension(Types.class, new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));
 
         addWSDLSchemaImport(wsdlSchema, tns, file);
         types.addExtensibilityElement(wsdlSchema);
@@ -236,10 +222,9 @@ public class WSDLSchemaManager {
 
     private void addWSDLSchemaImport(Schema wsdlSchema, String tns, File file) {
         if (!wsdlSchema.getImports().containsKey(tns)) {
-            SchemaImport schemaimport =  wsdlSchema.createImport();
+            SchemaImport schemaimport = wsdlSchema.createImport();
             schemaimport.setNamespaceURI(tns);
-            if (file != null
-                && !ignoreImports) {
+            if (file != null && !ignoreImports) {
                 schemaimport.setSchemaLocationURI(file.toURI().toString());
             }
             wsdlSchema.addImport(schemaimport);
@@ -247,7 +232,7 @@ public class WSDLSchemaManager {
     }
 
     private void addCorbaExtensions(ExtensionRegistry extReg) throws JAXBException {
-        try {                      
+        try {
             JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class);
             JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class, OperationType.class);
             JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class);
@@ -264,16 +249,16 @@ public class WSDLSchemaManager {
             throw new JAXBException(ex.getMessage());
         }
     }
-    
-    public void deferAttachSchemaToWSDL(Definition definition, XmlSchema schema, 
-                                        boolean isSchemaGenerated) throws Exception {
+
+    public void deferAttachSchemaToWSDL(Definition definition, XmlSchema schema, boolean isSchemaGenerated)
+        throws Exception {
         DeferredSchemaAttachment attachment = new DeferredSchemaAttachment();
         attachment.defn = definition;
         attachment.schema = schema;
         attachment.isGenerated = isSchemaGenerated;
         deferredAttachments.add(attachment);
     }
-    
+
     public void attachDeferredSchemasToWSDL() throws Exception {
         for (Iterator<DeferredSchemaAttachment> iter = deferredAttachments.iterator(); iter.hasNext();) {
             DeferredSchemaAttachment attachment = iter.next();
@@ -288,18 +273,16 @@ public class WSDLSchemaManager {
             types = definition.createTypes();
             definition.setTypes(types);
         }
-        Schema wsdlSchema = (Schema) 
-            definition.getExtensionRegistry().createExtension(Types.class,
-                                                              new QName(Constants.URI_2001_SCHEMA_XSD,
-                                                                        "schema"));
+        Schema wsdlSchema = (Schema)definition.getExtensionRegistry()
+            .createExtension(Types.class, new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));
 
-        // See if a NamespaceMap has already been added to the schema (this can be the case with object 
-        // references.  If so, simply add the XSD URI to the map.  Otherwise, create a new one.
+        // See if a NamespaceMap has already been added to the schema (this can be the case with object
+        // references. If so, simply add the XSD URI to the map. Otherwise, create a new one.
         NamespaceMap nsMap = null;
         try {
             nsMap = (NamespaceMap)schema.getNamespaceContext();
         } catch (ClassCastException ex) {
-            // Consume.  This will mean that the context has not been set.
+            // Consume. This will mean that the context has not been set.
         }
         if (nsMap == null) {
             nsMap = new NamespaceMap();
@@ -313,30 +296,28 @@ public class WSDLSchemaManager {
         }
         org.w3c.dom.Element el = schema.getAllSchemas()[0].getDocumentElement();
         wsdlSchema.setElement(el);
-        
-        XmlSchemaObjectCollection imports = schema.getIncludes();
-        for (java.util.Iterator<XmlSchemaObject> it = CastUtils.cast(imports.getIterator()); it.hasNext();) {
-            XmlSchemaImport xmlSchemaImport = (XmlSchemaImport) it.next();
-            SchemaImport schemaimport =  wsdlSchema.createImport();
-            schemaimport.setNamespaceURI(xmlSchemaImport.getNamespace());
-            if (xmlSchemaImport.getSchemaLocation() != null
-                && !ignoreImports) {
-                schemaimport.setSchemaLocationURI(xmlSchemaImport.getSchemaLocation());
+
+        for (XmlSchemaExternal ext : schema.getExternals()) {
+            if (ext instanceof XmlSchemaImport) {
+                XmlSchemaImport xmlSchemaImport = (XmlSchemaImport)ext;
+                SchemaImport schemaimport = wsdlSchema.createImport();
+                schemaimport.setNamespaceURI(xmlSchemaImport.getNamespace());
+                if (xmlSchemaImport.getSchemaLocation() != null && !ignoreImports) {
+                    schemaimport.setSchemaLocationURI(xmlSchemaImport.getSchemaLocation());
+                }
+                wsdlSchema.addImport(schemaimport);
             }
-            wsdlSchema.addImport(schemaimport);  
         }
         types.addExtensibilityElement(wsdlSchema);
     }
 
     public TypeMappingType createCorbaTypeMap(Definition definition, String corbatypemaptns)
-        throws WSDLException { 
-        TypeMappingType typeMap = (TypeMappingType)
-            definition.getExtensionRegistry().createExtension(Definition.class,
-                                                              CorbaConstants.NE_CORBA_TYPEMAPPING);
+        throws WSDLException {
+        TypeMappingType typeMap = (TypeMappingType)definition.getExtensionRegistry()
+            .createExtension(Definition.class, CorbaConstants.NE_CORBA_TYPEMAPPING);
         if (corbatypemaptns == null) {
-            typeMap.setTargetNamespace(definition.getTargetNamespace()
-                + "/"
-                + CorbaConstants.NS_CORBA_TYPEMAP);
+            typeMap.setTargetNamespace(definition.getTargetNamespace() + "/"
+                                       + CorbaConstants.NS_CORBA_TYPEMAP);
         } else {
             typeMap.setTargetNamespace(corbatypemaptns);
         }



Mime
View raw message