cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1023402 [7/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/wsdl/WSDLParameter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java Sun Oct 17 02:26:06 2010
@@ -39,25 +39,24 @@ import org.apache.cxf.binding.corba.wsdl
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotationItem;
 import org.apache.ws.commons.schema.XmlSchemaAppInfo;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 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.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 public final class WSDLParameter {
 
     static Definition definition;
 
-    public void processParameters(WSDLToCorbaBinding wsdlToCorbaBinding,
-            Operation operation, Definition def, SchemaCollection xmlSchemaList,
-            List<ParamType> params, List<ArgType> returns,
-            boolean simpleOrdering) throws Exception {
+    public void processParameters(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, Definition def,
+                                  SchemaCollection xmlSchemaList, List<ParamType> params,
+                                  List<ArgType> returns, boolean simpleOrdering) throws Exception {
 
         definition = def;
         List<ParamType> inputs = new ArrayList<ParamType>();
@@ -66,18 +65,14 @@ public final class WSDLParameter {
         boolean isWrapped = isWrappedOperation(operation, xmlSchemaList);
 
         if (isWrapped) {
-            processWrappedInputParams(wsdlToCorbaBinding, operation,
-                    xmlSchemaList, inputs);
+            processWrappedInputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs);
         } else {
-            processInputParams(wsdlToCorbaBinding, operation, xmlSchemaList,
-                    inputs);
+            processInputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs);
         }
         if (isWrapped) {
-            processWrappedOutputParams(wsdlToCorbaBinding, operation,
-                    xmlSchemaList, inputs, outputs);
+            processWrappedOutputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs, outputs);
         } else {
-            processOutputParams(wsdlToCorbaBinding, operation, xmlSchemaList,
-                    inputs, outputs);
+            processOutputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs, outputs);
         }
         processReturnParams(outputs, returnOutputs);
         orderParameters(inputs, outputs, true);
@@ -86,55 +81,47 @@ public final class WSDLParameter {
 
     }
 
-    private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding,
-                                           Operation operation,
-                                           SchemaCollection xmlSchemaList,
-                                           List<ParamType> inputs)
+    private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation,
+                                           SchemaCollection xmlSchemaList, List<ParamType> inputs)
         throws Exception {
         Input input = operation.getInput();
 
         if (input != null) {
             Message msg = input.getMessage();
-            Part part = (Part) msg.getOrderedParts(null).iterator().next();
+            Part part = (Part)msg.getOrderedParts(null).iterator().next();
 
             XmlSchemaComplexType schemaType = null;
 
             XmlSchemaElement el = getElement(part, xmlSchemaList);
             if ((el != null) && (el.getSchemaType() != null)) {
-                schemaType = (XmlSchemaComplexType) el.getSchemaType();
+                schemaType = (XmlSchemaComplexType)el.getSchemaType();
             }
-          
-            XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
+
+            XmlSchemaSequence seq = (XmlSchemaSequence)schemaType.getParticle();
             if (seq != null) {
-                XmlSchemaObjectCollection items = seq.getItems();
-                for (int i = 0; i < items.getCount(); i++) {
-                    el = (XmlSchemaElement) items.getItem(i);
-                    //REVISIT, handle element ref's?
-                    QName typeName = el.getSchemaTypeName();
-                    if (typeName == null) {
-                        typeName = el.getQName();
-                    }
-                    QName idltype = getIdlType(wsdlToCorbaBinding,
-                                               el.getSchemaType(),
-                                               typeName,
-                                               el.isNillable());
-                    ParamType paramtype = createParam(wsdlToCorbaBinding,
-                                                      "in",
-                                                      el.getQName().getLocalPart(),
-                                                      idltype);
-                    if (paramtype != null) {
-                        inputs.add(paramtype);
+                for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
+                    if (seqItem instanceof XmlSchemaElement) {
+                        el = (XmlSchemaElement)seqItem;
+                        // REVISIT, handle element ref's?
+                        QName typeName = el.getSchemaTypeName();
+                        if (typeName == null) {
+                            typeName = el.getQName();
+                        }
+                        QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName,
+                                                   el.isNillable());
+                        ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName()
+                            .getLocalPart(), idltype);
+                        if (paramtype != null) {
+                            inputs.add(paramtype);
+                        }
                     }
                 }
-            }       
+            }
         }
     }
 
-    private void processInputParams(WSDLToCorbaBinding wsdlToCorbaBinding,
-                                    Operation operation,
-                                    SchemaCollection xmlSchemaList,
-                                    List<ParamType> inputs)
-        throws Exception {
+    private void processInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation,
+                                    SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
 
         Input input = operation.getInput();
 
@@ -142,7 +129,7 @@ public final class WSDLParameter {
             Message msg = input.getMessage();
             Iterator i = msg.getOrderedParts(null).iterator();
             while (i.hasNext()) {
-                Part part = (Part) i.next();
+                Part part = (Part)i.next();
                 XmlSchemaType schemaType = null;
                 boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
                 if (part.getElementName() != null && !isObjectRef) {
@@ -154,14 +141,8 @@ public final class WSDLParameter {
                     if (typeName == null) {
                         typeName = el.getQName();
                     }
-                    QName idltype = getIdlType(wsdlToCorbaBinding,
-                                               schemaType,
-                                               typeName,
-                                               el.isNillable());
-                    ParamType paramtype = createParam(wsdlToCorbaBinding,
-                                                      "in",
-                                                      part.getName(),
-                                                      idltype);
+                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
+                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                     if (paramtype != null) {
                         inputs.add(paramtype);
                     }
@@ -171,14 +152,8 @@ public final class WSDLParameter {
                     if (isObjectRef) {
                         typeName = part.getElementName();
                     }
-                    QName idltype = getIdlType(wsdlToCorbaBinding,
-                                               schemaType,
-                                               typeName,
-                                               false);
-                    ParamType paramtype = createParam(wsdlToCorbaBinding,
-                                                      "in",
-                                                      part.getName(),
-                                                      idltype);
+                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
+                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                     if (paramtype != null) {
                         inputs.add(paramtype);
                     }
@@ -187,38 +162,35 @@ public final class WSDLParameter {
         }
     }
 
-    private void processWrappedOutputParams(
-            WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation,
-            SchemaCollection xmlSchemaList, List<ParamType> inputs,
-            List<ParamType> outputs) throws Exception {
+    private void processWrappedOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation,
+                                            SchemaCollection xmlSchemaList, List<ParamType> inputs,
+                                            List<ParamType> outputs) throws Exception {
 
         Output output = operation.getOutput();
 
         if (output != null) {
             Message msg = output.getMessage();
-            Part part = (Part) msg.getOrderedParts(null).iterator().next();
+            Part part = (Part)msg.getOrderedParts(null).iterator().next();
             XmlSchemaComplexType schemaType = null;
 
             XmlSchemaElement el = getElement(part, xmlSchemaList);
             if (el != null && el.getSchemaType() != null) {
-                schemaType = (XmlSchemaComplexType) el.getSchemaType();
+                schemaType = (XmlSchemaComplexType)el.getSchemaType();
             }
-            XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
+            XmlSchemaSequence seq = (XmlSchemaSequence)schemaType.getParticle();
             if (seq != null) {
-                XmlSchemaObjectCollection items = seq.getItems();
-                for (int i = 0; i < items.getCount(); i++) {
-                    el = (XmlSchemaElement) items.getItem(i);
-                    processWrappedOutputParam(wsdlToCorbaBinding, el, inputs, outputs);
+                for (XmlSchemaSequenceMember seqMember : seq.getItems()) {
+                    if (seqMember instanceof XmlSchemaElement) {
+                        el = (XmlSchemaElement)seqMember;
+                        processWrappedOutputParam(wsdlToCorbaBinding, el, inputs, outputs);
+                    }
                 }
             }
         }
     }
 
-    private void processWrappedOutputParam(WSDLToCorbaBinding wsdlToCorbaBinding,
-                                           XmlSchemaElement el,
-                                           List<ParamType> inputs,
-                                           List<ParamType> outputs)
-        throws Exception {
+    private void processWrappedOutputParam(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaElement el,
+                                           List<ParamType> inputs, List<ParamType> outputs) throws Exception {
         ParamType paramtype = null;
         for (int i = 0; i < inputs.size(); i++) {
             if (inputs.get(i).getName().equals(el.getQName().getLocalPart())) {
@@ -227,14 +199,8 @@ public final class WSDLParameter {
                 if (typeName == null) {
                     typeName = el.getQName();
                 }
-                QName idltype = getIdlType(wsdlToCorbaBinding,
-                                           el.getSchemaType(),
-                                           typeName,
-                                           el.isNillable());
-                paramtype = createParam(wsdlToCorbaBinding,
-                                        "inout",
-                                        el.getQName().getLocalPart(),
-                                        idltype);
+                QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
+                paramtype = createParam(wsdlToCorbaBinding, "inout", el.getQName().getLocalPart(), idltype);
                 if (paramtype != null) {
                     inputs.add(paramtype);
                 }
@@ -245,23 +211,17 @@ public final class WSDLParameter {
             if (typeName == null) {
                 typeName = el.getQName();
             }
-            QName idltype = getIdlType(wsdlToCorbaBinding,
-                                       el.getSchemaType(),
-                                       typeName,
-                                       el.isNillable());
-            paramtype = createParam(wsdlToCorbaBinding,
-                                    "out",
-                                    el.getQName().getLocalPart(),
-                                    idltype);
+            QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
+            paramtype = createParam(wsdlToCorbaBinding, "out", el.getQName().getLocalPart(), idltype);
             if (paramtype != null) {
                 outputs.add(paramtype);
             }
         }
     }
 
-    private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding,
-            Operation operation, SchemaCollection xmlSchemaList,
-            List<ParamType> inputs, List<ParamType> outputs) throws Exception {
+    private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation,
+                                     SchemaCollection xmlSchemaList, List<ParamType> inputs,
+                                     List<ParamType> outputs) throws Exception {
 
         Output output = operation.getOutput();
 
@@ -269,7 +229,7 @@ public final class WSDLParameter {
             Message msg = output.getMessage();
             Iterator i = msg.getOrderedParts(null).iterator();
             while (i.hasNext()) {
-                Part part = (Part) i.next();
+                Part part = (Part)i.next();
                 XmlSchemaType schemaType = null;
                 // check if in input list
                 String mode = "out";
@@ -277,10 +237,9 @@ public final class WSDLParameter {
                 boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
                 for (int x = 0; x < inputs.size(); x++) {
                     paramtype = null;
-                    ParamType d2 = (ParamType) inputs.get(x);
+                    ParamType d2 = (ParamType)inputs.get(x);
                     if (part.getElementName() != null && !isObjectRef) {
-                        XmlSchemaElement el = getElement(part,
-                                                         xmlSchemaList);
+                        XmlSchemaElement el = getElement(part, xmlSchemaList);
                         if (el != null && el.getSchemaType() != null) {
                             schemaType = el.getSchemaType();
                         }
@@ -288,17 +247,10 @@ public final class WSDLParameter {
                         if (typeName == null) {
                             typeName = el.getQName();
                         }
-                        QName idltype = getIdlType(wsdlToCorbaBinding,
-                                                   schemaType,
-                                                   typeName,
-                                                   el.isNillable());
-                        if ((d2.getName().equals(part.getName()))
-                            && (d2.getIdltype().equals(idltype))) {
+                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
+                        if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                             inputs.remove(x);
-                            paramtype = createParam(wsdlToCorbaBinding,
-                                                    "inout",
-                                                    part.getName(),
-                                                    idltype);
+                            paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                             inputs.add(paramtype);
                         }
                     } else {
@@ -307,17 +259,10 @@ public final class WSDLParameter {
                         if (isObjectRef) {
                             typeName = part.getElementName();
                         }
-                        QName idltype = getIdlType(wsdlToCorbaBinding,
-                                                   schemaType,
-                                                   typeName,
-                                                   false);
-                        if ((d2.getName().equals(part.getName()))
-                            && (d2.getIdltype().equals(idltype))) {
+                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
+                        if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                             inputs.remove(x);
-                            paramtype = createParam(wsdlToCorbaBinding,
-                                                    "inout",
-                                                    part.getName(),
-                                                    idltype);
+                            paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                             inputs.add(paramtype);
                         }
                     }
@@ -329,27 +274,15 @@ public final class WSDLParameter {
                         if (typeName == null) {
                             typeName = el.getQName();
                         }
-                        QName idltype = getIdlType(wsdlToCorbaBinding,
-                                                   schemaType,
-                                                   typeName,
-                                                   el.isNillable());
-                        paramtype = createParam(wsdlToCorbaBinding,
-                                                mode,
-                                                part.getName(),
-                                                idltype);
+                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
+                        paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                     } else {
                         QName typeName = part.getTypeName();
                         if (isObjectRef) {
                             typeName = part.getElementName();
                         }
-                        QName idltype = getIdlType(wsdlToCorbaBinding,
-                                                   schemaType,
-                                                   typeName,
-                                                   false);
-                        paramtype = createParam(wsdlToCorbaBinding,
-                                                mode,
-                                                part.getName(),
-                                                idltype);
+                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
+                        paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                     }
                     if (paramtype != null) {
                         outputs.add(paramtype);
@@ -359,11 +292,10 @@ public final class WSDLParameter {
         }
     }
 
-    private void processReturnParams(List<ParamType> outputs,
-                                     List<ArgType> returns) {
+    private void processReturnParams(List<ParamType> outputs, List<ArgType> returns) {
 
         if (outputs.size() > 0) {
-            ParamType d2 = (ParamType) outputs.get(0);
+            ParamType d2 = (ParamType)outputs.get(0);
 
             if (d2.getMode().value().equals("out")) {
                 ArgType argType = new ArgType();
@@ -375,19 +307,17 @@ public final class WSDLParameter {
         }
     }
 
-    private void orderParameters(List<ParamType> inputs,
-            List<ParamType> outputs, boolean simpleOrdering) {
+    private void orderParameters(List<ParamType> inputs, List<ParamType> outputs, boolean simpleOrdering) {
         ListIterator<ParamType> inputit = inputs.listIterator();
 
         while (inputit.hasNext()) {
-            ParamType d2 = (ParamType) inputit.next();
+            ParamType d2 = (ParamType)inputit.next();
             if (d2.getMode().value().equals("inout")) {
                 ListIterator it = outputs.listIterator();
 
                 while (it.hasNext()) {
-                    ParamType d3 = (ParamType) it.next();
-                    if (!d3.getName().equals(d2.getName()) 
-                        && (!simpleOrdering)
+                    ParamType d3 = (ParamType)it.next();
+                    if (!d3.getName().equals(d2.getName()) && (!simpleOrdering)
                         && (!d3.getMode().value().equals("inout"))) {
                         // the in/outs are in a different order in the
                         // output than the input
@@ -407,27 +337,25 @@ public final class WSDLParameter {
         }
     }
 
-    private static XmlSchemaType getType(Part part,
-                                         SchemaCollection xmlSchemaList)
-        throws Exception {
+    private static XmlSchemaType getType(Part part, SchemaCollection xmlSchemaList) throws Exception {
         XmlSchemaType schemaType = null;
 
         for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
             if (part.getTypeName() != null) {
-                schemaType = findSchemaType(xmlSchema, part.getTypeName());                
+                schemaType = findSchemaType(xmlSchema, part.getTypeName());
                 if (schemaType != null) {
                     return schemaType;
                 }
             }
         }
-            
+
         return schemaType;
     }
 
-    // This willl search the current schemas and any included 
+    // This willl search the current schemas and any included
     // schemas for the schema type.
     private static XmlSchemaType findSchemaType(XmlSchema xmlSchema, QName typeName) {
-                          
+
         XmlSchemaType schemaType = xmlSchema.getTypeByName(typeName);
 
         // Endpoint reference types will give a null schemaType
@@ -435,28 +363,21 @@ public final class WSDLParameter {
         // go through the list of imports to find the definition for
         // an Endpoint
         // reference type.
-                
-        if (schemaType == null
-            && xmlSchema.getIncludes().getCount() > 0) {
-            XmlSchemaObjectCollection includes = xmlSchema.getIncludes();
-            Iterator includeIter = includes.getIterator();
-            while (includeIter.hasNext()) {
-                Object obj = includeIter.next();
-                if (obj instanceof XmlSchemaExternal) {
-                    XmlSchemaExternal extSchema = (XmlSchemaExternal) obj;
-                    if (extSchema instanceof XmlSchemaImport) {
-                        XmlSchemaImport xmlImport = (XmlSchemaImport) obj;
-                        if (xmlImport.getNamespace().equals(typeName.getNamespaceURI())) {
-                            XmlSchema importSchema = xmlImport.getSchema();
-                            schemaType = importSchema.getTypeByName(typeName);
-                        }
+
+        if (schemaType == null) {
+            for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
+                if (ext instanceof XmlSchemaImport) {
+                    XmlSchemaImport xmlImport = (XmlSchemaImport)ext;
+                    if (xmlImport.getNamespace().equals(typeName.getNamespaceURI())) {
+                        XmlSchema importSchema = xmlImport.getSchema();
+                        schemaType = importSchema.getTypeByName(typeName);
                     } else {
-                        schemaType = findSchemaType(extSchema.getSchema(), typeName);
+                        schemaType = findSchemaType(ext.getSchema(), typeName);
                         if (schemaType != null) {
                             return schemaType;
                         }
-                    }                    
-                }                                
+                    }
+                }
             }
             if (schemaType != null) {
                 return schemaType;
@@ -465,80 +386,67 @@ public final class WSDLParameter {
         return schemaType;
     }
 
-    private static XmlSchemaElement getElement(Part part,
-                                               SchemaCollection xmlSchemaList)
-        throws Exception {
+    private static XmlSchemaElement getElement(Part part, SchemaCollection xmlSchemaList) throws Exception {
         XmlSchemaElement schemaElement = null;
 
         for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
             if (part.getElementName() != null) {
-                schemaElement = findElement(xmlSchema, part.getElementName()); 
-                if (schemaElement !=  null) {
+                schemaElement = findElement(xmlSchema, part.getElementName());
+                if (schemaElement != null) {
                     return schemaElement;
                 }
             }
         }
         return schemaElement;
     }
-    
+
     // Will check if the schema includes other schemas.
     private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName elName) {
         XmlSchemaElement schemaElement = null;
-        
+
         schemaElement = xmlSchema.getElementByName(elName);
-        if (schemaElement == null) {           
+        if (schemaElement == null) {
             String prefix = definition.getPrefix(elName.getNamespaceURI());
-            QName name = new QName(elName.getNamespaceURI(), prefix
-                                   + ":" + elName.getLocalPart(), prefix);
+            QName name = new QName(elName.getNamespaceURI(), prefix + ":" + elName.getLocalPart(), prefix);
             schemaElement = xmlSchema.getElementByName(name);
         }
         if (schemaElement != null) {
             return schemaElement;
-        } else {            
-            if (xmlSchema.getIncludes() != null) {
-                Iterator schemas = xmlSchema.getIncludes().getIterator();
-                while (schemas.hasNext()) {
-                    Object obj = schemas.next();
-                    if (obj instanceof XmlSchemaExternal) {
-                        XmlSchemaExternal extSchema = (XmlSchemaExternal) obj;
-                        if (!(extSchema instanceof XmlSchemaImport)) {
-                            schemaElement = findElement(extSchema.getSchema(), elName);
-                            if (schemaElement != null) {
-                                return schemaElement;
-                            }
-                        }
+        } else {
+            for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
+                if (!(ext instanceof XmlSchemaImport)) {
+                    schemaElement = findElement(ext.getSchema(), elName);
+                    if (schemaElement != null) {
+                        return schemaElement;
                     }
-                }                
+                }
             }
-        }      
+        }
         return schemaElement;
     }
 
-    private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding,
-        XmlSchemaType schemaType, QName typeName, boolean nill)
-        throws Exception {
+    private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType,
+                                    QName typeName, boolean nill) throws Exception {
         QName idltype = null;
         CorbaTypeImpl corbaTypeImpl = null;
         if (schemaType == null) {
-            corbaTypeImpl = (CorbaTypeImpl) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
+            corbaTypeImpl = (CorbaTypeImpl)WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
             if (nill) {
                 QName qname = corbaTypeImpl.getQName();
-                idltype = 
-                    wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
+                idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart()
+                                                                                       + "_nil");
             } else {
                 if (corbaTypeImpl == null) {
-                    XmlSchemaObject schemaObj = getSchemaObject(
-                        wsdlToCorbaBinding, typeName);
+                    XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
                     XmlSchemaAnnotation annotation = null;
                     if (schemaObj instanceof XmlSchemaType) {
-                        schemaType = (XmlSchemaType) schemaObj;
+                        schemaType = (XmlSchemaType)schemaObj;
                     } else if (schemaObj instanceof XmlSchemaElement) {
-                        XmlSchemaElement el = (XmlSchemaElement) schemaObj;
+                        XmlSchemaElement el = (XmlSchemaElement)schemaObj;
                         schemaType = el.getSchemaType();
-                        annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
+                        annotation = ((XmlSchemaElement)schemaObj).getAnnotation();
                     }
-                    idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType,
-                        annotation, typeName, nill);
+                    idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
                 } else {
                     idltype = corbaTypeImpl.getQName();
                 }
@@ -550,44 +458,40 @@ public final class WSDLParameter {
             XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
             XmlSchemaAnnotation annotation = null;
             if (schemaObj instanceof XmlSchemaElement) {
-                annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
+                annotation = ((XmlSchemaElement)schemaObj).getAnnotation();
             }
-            idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType,
-                annotation, typeName, nill);
+            idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
         }
         return idltype;
     }
 
-    private static XmlSchemaObject getSchemaObject(
-        WSDLToCorbaBinding wsdlToCorbaBinding, QName typeName) {
+    private static XmlSchemaElement getSchemaObject(WSDLToCorbaBinding wsdlToCorbaBinding, QName typeName) {
 
         SchemaCollection schemaList = wsdlToCorbaBinding.getHelper().getXMLSchemaList();
-        XmlSchemaObject schemaObj = null;
         for (XmlSchema s : schemaList.getXmlSchemas()) {
-            XmlSchemaObjectTable schemaTable = s.getElements();
-            schemaObj = schemaTable.getItem(typeName);
-            if (schemaObj != null) {
-                break;
+            XmlSchemaElement e = s.getElementByName(typeName);
+            if (e != null) {
+                return e;
             }
         }
-        return schemaObj;
+        return null;
     }
 
-    private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding, 
-        XmlSchemaType schemaType, XmlSchemaAnnotation annotation, QName typeName, 
-        boolean nill) throws Exception {
+    private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType,
+                                           XmlSchemaAnnotation annotation, QName typeName, boolean nill)
+        throws Exception {
         QName idltype = null;
         CorbaTypeImpl corbaTypeImpl = null;
 
-        corbaTypeImpl = wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, 
-            typeName, null, annotation, false);
+        corbaTypeImpl = wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, typeName, null,
+                                                                                annotation, false);
         if (corbaTypeImpl == null) {
             throw new Exception("Couldn't convert schema type to corba type : " + typeName);
         } else {
             if (nill) {
                 QName qname = corbaTypeImpl.getQName();
-                idltype = 
-                    wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
+                idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart()
+                                                                                       + "_nil");
             } else {
                 idltype = corbaTypeImpl.getQName();
             }
@@ -595,12 +499,8 @@ public final class WSDLParameter {
         return idltype;
     }
 
-
-    private static ParamType createParam(WSDLToCorbaBinding wsdlToCorbaBinding,
-                                         String mode,
-                                         String name,
-                                         QName idltype)
-        throws Exception {
+    private static ParamType createParam(WSDLToCorbaBinding wsdlToCorbaBinding, String mode, String name,
+                                         QName idltype) throws Exception {
         ParamType paramtype = new ParamType();
         ModeType modeType = ModeType.fromValue(mode);
         paramtype.setName(name);
@@ -609,8 +509,7 @@ public final class WSDLParameter {
         return paramtype;
     }
 
-    private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList)
-        throws Exception {
+    private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
         Message inputMessage = op.getInput().getMessage();
         Message outputMessage = null;
         if (op.getOutput() != null) {
@@ -639,7 +538,7 @@ public final class WSDLParameter {
         // The input message part refers to a global element decalration whose
         // localname
         // is equal to the operation name
-        Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
+        Part inputPart = (Part)inputMessage.getParts().values().iterator().next();
         if (inputPart.getElementName() == null) {
             passedRule = false;
         } else {
@@ -649,7 +548,7 @@ public final class WSDLParameter {
                 passedRule = false;
             }
         }
-        
+
         if (!passedRule) {
             return false;
         }
@@ -658,17 +557,16 @@ public final class WSDLParameter {
         // The output message part refers to a global element declaration
         Part outputPart = null;
         if (outputMessage != null && outputMessage.getParts().size() == 1) {
-            outputPart = (Part) outputMessage.getParts().values().iterator().next();
+            outputPart = (Part)outputMessage.getParts().values().iterator().next();
             if (outputPart != null) {
-                if ((outputPart.getElementName() == null)
-                    || getElement(outputPart, xmlSchemaList) == null) {
+                if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
                     passedRule = false;
                 } else {
                     outputEl = getElement(outputPart, xmlSchemaList);
                 }
             }
         }
-        
+
         if (!passedRule) {
             return false;
         }
@@ -682,14 +580,13 @@ public final class WSDLParameter {
         XmlSchemaComplexType xsct = null;
         if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
             xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
-            if (hasAttributes(xsct)
-                || !isWrappableSequence(xsct)) {
+            if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
                 passedRule = false;
             }
         } else {
             passedRule = false;
         }
-        
+
         if (!passedRule) {
             return false;
         }
@@ -697,14 +594,13 @@ public final class WSDLParameter {
         if (outputMessage != null) {
             if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
                 xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
-                if (hasAttributes(xsct)
-                    || !isWrappableSequence(xsct)) {
+                if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
                     passedRule = false;
                 }
             } else {
                 passedRule = false;
             }
-        }       
+        }
 
         return passedRule;
     }
@@ -712,7 +608,7 @@ public final class WSDLParameter {
     private boolean hasAttributes(XmlSchemaComplexType complexType) {
         // Now lets see if we have any attributes...
         // This should probably look at the restricted and substitute types too.
-        if (complexType.getAnyAttribute() != null || complexType.getAttributes().getCount() > 0) {
+        if (complexType.getAnyAttribute() != null || complexType.getAttributes().size() > 0) {
             return true;
         }
         return false;
@@ -721,11 +617,10 @@ public final class WSDLParameter {
     private boolean isWrappableSequence(XmlSchemaComplexType type) {
         if (type.getParticle() instanceof XmlSchemaSequence) {
             XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
-            XmlSchemaObjectCollection items = seq.getItems();
+            List<XmlSchemaSequenceMember> items = seq.getItems();
 
-            for (int x = 0; x < items.getCount(); x++) {
-                XmlSchemaObject o = items.getItem(x);
-                if (!(o instanceof XmlSchemaElement)) {
+            for (XmlSchemaSequenceMember member : items) {
+                if (!(member instanceof XmlSchemaElement)) {
                     return false;
                 }
             }
@@ -743,18 +638,15 @@ public final class WSDLParameter {
             if (element != null) {
                 XmlSchemaAnnotation annotation = element.getAnnotation();
                 if (annotation != null) {
-                    XmlSchemaObjectCollection annotationColl = annotation.getItems();
-                    Iterator annotationIter = annotationColl.getIterator();
-                    while (annotationIter.hasNext()) {
-                        Object o = annotationIter.next();
-                        if (o instanceof XmlSchemaAppInfo) {
+                    List<XmlSchemaAnnotationItem> annotationColl = annotation.getItems();
+                    for (XmlSchemaAnnotationItem item : annotationColl) {
+                        if (item instanceof XmlSchemaAppInfo) {
                             return true;
                         }
                     }
                 }
             }
         }
-
         return false;
     }
 

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java Sun Oct 17 02:26:06 2010
@@ -69,24 +69,24 @@ import org.apache.cxf.tools.common.ToolE
 import org.apache.cxf.wsdl.JAXBExtensionHelper;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotationItem;
 import org.apache.ws.commons.schema.XmlSchemaAppInfo;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaExternal;
-import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 public class WSDLToCorbaBinding {
-    
+
     protected static final Logger LOG = LogUtils.getL7dLogger(WSDLToCorbaBinding.class);
-           
-    static XmlSchema xmlSchemaType;                   
+
+    static XmlSchema xmlSchemaType;
     static String wsdlFileName;
     static String outputFile;
     static String namespace;
-    static boolean verboseOn;    
+    static boolean verboseOn;
     protected Definition def;
-    protected String idlNamespace;    
+    protected String idlNamespace;
 
     WSDLToCorbaHelper helper = new WSDLToCorbaHelper();
     TypeMappingType typeMappingType;
@@ -102,28 +102,28 @@ public class WSDLToCorbaBinding {
     SchemaCollection xmlSchemaList;
     WSDLToTypeProcessor typeProcessor = new WSDLToTypeProcessor();
     private boolean allbindings;
-        
-    public WSDLToCorbaBinding() {            
+
+    public WSDLToCorbaBinding() {
     }
 
 
     public WSDLToCorbaHelper getHelper() {
         return helper;
     }
-    
+
 
     public Definition generateCORBABinding() throws Exception {
         try {
-            typeProcessor.parseWSDL(getWsdlFileName());           
+            typeProcessor.parseWSDL(getWsdlFileName());
             def = typeProcessor.getWSDLDefinition();
-            generateCORBABinding(def);            
+            generateCORBABinding(def);
         } catch (Exception ex) {
             throw ex;
         }
         return def;
     }
 
-    public Binding[] generateCORBABinding(Definition definition) throws Exception {    
+    public Binding[] generateCORBABinding(Definition definition) throws Exception {
         def = definition;
         helper.setWsdlDefinition(def);
         typeProcessor.setWSDLDefinition(def);
@@ -136,7 +136,7 @@ public class WSDLToCorbaBinding {
         typeProcessor.process();
         xmlSchemaList = typeProcessor.getXmlSchemaTypes();
         helper.setXMLSchemaList(xmlSchemaList);
-        
+
         List<PortType> intfs = null;
         if (interfaceNames.size() > 0) {
             intfs = new ArrayList<PortType>(interfaceNames.size());
@@ -158,9 +158,9 @@ public class WSDLToCorbaBinding {
                     }
                 }
 
-                if (portType == null) {                    
-                    String msgStr = "PortType " + interfaceName 
-                        + " doesn't exist in WSDL.";                     
+                if (portType == null) {
+                    String msgStr = "PortType " + interfaceName
+                        + " doesn't exist in WSDL.";
                     throw new Exception(msgStr);
                 }
                 intfs.add(portType);
@@ -191,26 +191,26 @@ public class WSDLToCorbaBinding {
             intfs = new ArrayList<PortType>();
             if (portTypes.size() == 1) {
                 portType = (PortType) portTypes.values().iterator().next();
-                interfaceNames.add(portType.getQName().getLocalPart());                    
+                interfaceNames.add(portType.getQName().getLocalPart());
                 intfs.add(portType);
             } else if (portTypes.size() > 1) {
                 if (def.getAllBindings().size() > 0) {
                     throwMultipleMultipleTypeException(def.getAllBindings());
                 }
                 Iterator iter = portTypes.values().iterator();
-                while (iter.hasNext()) {                    
+                while (iter.hasNext()) {
                     PortType port = (PortType)iter.next();
-                    interfaceNames.add(port.getQName().getLocalPart());                        
+                    interfaceNames.add(port.getQName().getLocalPart());
                     intfs.add(port);
-                }                    
+                }
             }
         }
         return intfs;
     }
-    
+
     private void throwMultipleMultipleTypeException(Map binds) throws Exception {
         StringBuilder sb = new StringBuilder();
-        org.apache.cxf.common.i18n.Message msgDef = 
+        org.apache.cxf.common.i18n.Message msgDef =
             new org.apache.cxf.common.i18n.Message("Multiple Bindings already defined in the wsdl", LOG);
         sb.append(msgDef.toString());
         Iterator it2 = binds.keySet().iterator();
@@ -233,7 +233,7 @@ public class WSDLToCorbaBinding {
         bindingNames = new ArrayList<String>();
         String interfaceName = portType.getQName().getLocalPart();
         String bname = getMappedBindingName(interfaceName);
-    
+
         String prefix = definition.getPrefix(definition.getTargetNamespace());
         if (prefix == null) {
             prefix = "";
@@ -254,11 +254,11 @@ public class WSDLToCorbaBinding {
             bqname = new QName(definition.getTargetNamespace(), bname, prefix);
             // Check if the Binding with name already exists
             if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
-                String msgStr = "Binding " + bqname.getLocalPart() 
+                String msgStr = "Binding " + bqname.getLocalPart()
                     + " already exists in WSDL.";
-                org.apache.cxf.common.i18n.Message msg = 
+                org.apache.cxf.common.i18n.Message msg =
                     new org.apache.cxf.common.i18n.Message(msgStr, LOG);
-                throw new Exception(msg.toString());                    
+                throw new Exception(msg.toString());
             }
         }
 
@@ -277,9 +277,9 @@ public class WSDLToCorbaBinding {
         bindingNames.add(bname);
         mapBindingToInterface(portType.getQName().getLocalPart(), bname);
         BindingType bindingType = null;
-        
+
         addCorbaTypeMap(def);
-        
+
         try {
             bindingType = (BindingType)extReg
                 .createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
@@ -293,18 +293,18 @@ public class WSDLToCorbaBinding {
         }
 
         try {
-            addBindingOperations(def, portType, binding);        
+            addBindingOperations(def, portType, binding);
             binding.setUndefined(false);
-            definition.addBinding(binding);            
+            definition.addBinding(binding);
         } catch (Exception ex) {
             binding.setUndefined(true);
         }
 
         cleanUpTypeMap(typeMappingType);
-        
+
         return binding;
     }
-    
+
     private void generateCORBAServiceForBinding(Definition definition, PortType portType,
                                                 Binding binding) throws Exception {
         if (extReg == null) {
@@ -327,7 +327,7 @@ public class WSDLToCorbaBinding {
             corbaPrefix = new String("corba");
             def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
         }
-        
+
         // Build the service and port information and add it to the wsdl
         Service service = def.createService();
 
@@ -339,8 +339,8 @@ public class WSDLToCorbaBinding {
             AddressType addressType =
                 (AddressType) def.getExtensionRegistry().createExtension(Port.class,
                                                                          CorbaConstants.NE_CORBA_ADDRESS);
-            
-            String addr = null; 
+
+            String addr = null;
             if (getAddressFile() != null) {
                 try {
                     File addrFile = new File(getAddressFile());
@@ -354,23 +354,23 @@ public class WSDLToCorbaBinding {
                 addr = getAddress();
             }
             if (addr == null) {
-                addr = "file:./" + interfaceName + ".ref";            
+                addr = "file:./" + interfaceName + ".ref";
             }
             addressType.setLocation(addr);
             servicePort.addExtensibilityElement(addressType);
         } catch (WSDLException ex) {
             throw new Exception("Failed to create CORBA address for service", ex);
         }
-        
+
         QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
         service.setQName(serviceQName);
         service.addPort(servicePort);
         definition.addService(service);
     }
 
-    private void addBindingOperations(Definition definition, PortType portType, Binding binding) 
+    private void addBindingOperations(Definition definition, PortType portType, Binding binding)
         throws Exception {
-        
+
         List<Operation> ops = CastUtils.cast(portType.getOperations());
         for (Operation op : ops) {
             try {
@@ -390,13 +390,13 @@ public class WSDLToCorbaBinding {
                 // add Faults
                 if (op.getFaults() != null && op.getFaults().size() > 0) {
                     Map faults = op.getFaults();
-                    Iterator i = faults.values().iterator();               
+                    Iterator i = faults.values().iterator();
                     while (i.hasNext()) {
                         Fault fault = (Fault)i.next();
                         BindingFault bindingFault = definition.createBindingFault();
-                        bindingFault.setName(fault.getName());                    
+                        bindingFault.setName(fault.getName());
                         bindingOperation.addBindingFault(bindingFault);
-                    }               
+                    }
                 }
                 bindingOperation.setOperation(op);
                 binding.addBindingOperation(bindingOperation);
@@ -407,7 +407,7 @@ public class WSDLToCorbaBinding {
     }
 
     public void addExtensions(ExtensionRegistry extRegistry) throws JAXBException {
-        try {                      
+        try {
             JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class);
             JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class,
                                               org.apache.cxf.binding.corba.wsdl.OperationType.class);
@@ -426,16 +426,16 @@ public class WSDLToCorbaBinding {
             LOG.log(Level.SEVERE, "Failing to serialize/deserialize extensions", ex);
             throw new JAXBException(ex.getMessage());
         }
-    }    
-    
-    private void addCorbaOperationExtElement(BindingOperation bo, Operation op) 
+    }
+
+    private void addCorbaOperationExtElement(BindingOperation bo, Operation op)
         throws Exception {
 
         OperationType operationType = null;
         try {
             operationType = (OperationType)extReg.createExtension(BindingOperation.class,
                                                                   CorbaConstants.NE_CORBA_OPERATION);
-        } catch (WSDLException wse) {            
+        } catch (WSDLException wse) {
             LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
             throw new Exception(LOG.toString(), wse);
         }
@@ -454,21 +454,21 @@ public class WSDLToCorbaBinding {
         }
 
         Map faults = op.getFaults();
-        Iterator i = faults.values().iterator();               
+        Iterator i = faults.values().iterator();
         while (i.hasNext()) {
             Fault fault = (Fault)i.next();
-            RaisesType raisestype = new RaisesType();            
-            CorbaTypeImpl extype = convertFaultToCorbaType(xmlSchemaType, fault);           
+            RaisesType raisestype = new RaisesType();
+            CorbaTypeImpl extype = convertFaultToCorbaType(xmlSchemaType, fault);
             if (extype != null) {
-                raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));                
+                raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
                 operationType.getRaises().add(raisestype);
             }
         }
-               
+
         bo.addExtensibilityElement(operationType);
     }
 
-    
+
     private void addCorbaTypeMap(Definition definition) throws Exception {
 
         Iterator t = definition.getExtensibilityElements().iterator();
@@ -489,60 +489,51 @@ public class WSDLToCorbaBinding {
         helper.setTypeMap(typeMappingType);
         addCorbaTypes(definition);
     }
-    
-    private void addCorbaTypes(Definition definition) throws Exception {   
+
+    private void addCorbaTypes(Definition definition) throws Exception {
         for (XmlSchema xmlSchemaTypes : xmlSchemaList.getXmlSchemas()) {
-                
-            Iterator schemas = xmlSchemaTypes.getIncludes().getIterator();
-            while (schemas.hasNext()) {
-                Object obj = schemas.next();
-                if (obj instanceof XmlSchemaExternal) {
-                    XmlSchemaExternal extSchema = (XmlSchemaExternal) obj;                 
-                    addCorbaTypes(extSchema.getSchema());
-                    // REVISIT: This was preventing certain types from being added to the corba
-                    // typemap even when they are referenced from other parts of the wsdl.
-                    //
-                    // Should this add the corba types if it IS an instance of the XmlSchemaImport 
-                    // (and not an XmlSchemaInclude or XmlSchemaRedefine)?
-                    //if (!(extSchema instanceof XmlSchemaImport)) {
-                    //    addCorbaTypes(extSchema.getSchema());
-                    //}
-                }
+
+            for (XmlSchemaExternal ext : xmlSchemaTypes.getExternals()) {
+                addCorbaTypes(ext.getSchema());
+                // REVISIT: This was preventing certain types from being added to the corba
+                // typemap even when they are referenced from other parts of the wsdl.
+                //
+                // Should this add the corba types if it IS an instance of the XmlSchemaImport
+                // (and not an XmlSchemaInclude or XmlSchemaRedefine)?
+                //if (!(extSchema instanceof XmlSchemaImport)) {
+                //    addCorbaTypes(extSchema.getSchema());
+                //}
             }
             if (!W3CConstants.NU_SCHEMA_XSD.equals(xmlSchemaTypes.getTargetNamespace())) {
                 addCorbaTypes(xmlSchemaTypes);
             }
         }
-    }              
-    
+    }
+
     private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
-        XmlSchemaObjectTable objs = xmlSchemaTypes.getSchemaTypes(); 
-        Iterator i = objs.getValues();
+        Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
         CorbaTypeImpl corbaTypeImpl = null;
-        while (i.hasNext()) {                
-            XmlSchemaType type = (XmlSchemaType)i.next();
+        for (XmlSchemaType type : objs.values()) {
             boolean anonymous = WSDLTypes.isAnonymous(type.getName());
-            corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null, 
+            corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null,
                                                             null, anonymous);
             if (corbaTypeImpl != null
                 && !helper.isDuplicate(corbaTypeImpl)) {
                 typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
-            }                   
+            }
         }
         addCorbaElements(corbaTypeImpl, xmlSchemaTypes);
     }
 
-    
-    private void addCorbaElements(CorbaTypeImpl corbaTypeImpl, 
+
+    private void addCorbaElements(CorbaTypeImpl corbaTypeImpl,
                                   XmlSchema xmlSchemaTypes) throws Exception {
-        XmlSchemaObjectTable elements = xmlSchemaTypes.getElements();                            
-        Iterator i2 = elements.getValues();                
-        while (i2.hasNext()) {                
-            XmlSchemaElement el = (XmlSchemaElement)i2.next();
+        Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
+        for (XmlSchemaElement el : elements.values()) {
             QName elName = el.getQName();
             XmlSchemaType schemaType = el.getSchemaType();
             if (elName == null) {
-                elName = el.getRefName();
+                elName = el.getRef().getTargetQName();
                 schemaType = helper.getSchemaType(elName);
             }
             boolean anonymous = false;
@@ -551,26 +542,24 @@ public class WSDLToCorbaBinding {
             } else {
                 anonymous = WSDLTypes.isAnonymous(schemaType.getName());
             }
-            
+
             if (schemaType != null) {
                 XmlSchemaAnnotation annotation = null;
                 if (el.getAnnotation() != null) {
                     annotation = el.getAnnotation();
                 }
-                
+
                 // Check to see if this element references the binding we are creating.  For now,
                 // this situation won't be handled. REVISIT.
                 if (annotation != null) {
-                    Iterator i = annotation.getItems().getIterator();
                     XmlSchemaAppInfo appInfo = null;
-                    while (i.hasNext()) {
-                        Object item = i.next();
-                        if (item instanceof XmlSchemaAppInfo) {
-                            appInfo = (XmlSchemaAppInfo)item;
+                    for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
+                        if (ann instanceof XmlSchemaAppInfo) {
+                            appInfo = (XmlSchemaAppInfo)ann;
                             break;
                         }
                     }
-                    
+
                     if (appInfo != null) {
                         NodeList nlist = appInfo.getMarkup();
                         Node node = nlist.item(0);
@@ -585,39 +574,39 @@ public class WSDLToCorbaBinding {
                         }
                     }
                 }
-                corbaTypeImpl = 
+                corbaTypeImpl =
                     helper.convertSchemaToCorbaType(schemaType,
-                                                    elName, schemaType, 
+                                                    elName, schemaType,
                                                     annotation, anonymous);
-                if (el.isNillable()) {                            
-                    QName uname =  
+                if (el.isNillable()) {
+                    QName uname =
                         helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                     boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
-                    corbaTypeImpl = helper.createNillableUnion(uname, 
+                    corbaTypeImpl = helper.createNillableUnion(uname,
                                                                helper.checkPrefix(elName),
                                                                helper.checkPrefix(corbaTypeImpl.getQName()),
                                                                isQualified);
-                } 
+                }
 
                 if (corbaTypeImpl != null
                     && !helper.isDuplicate(corbaTypeImpl)) {
                     typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
                 }
-            }                   
+            }
         }
-    }    
+    }
 
     private CorbaTypeImpl convertFaultToCorbaType(XmlSchema xmlSchema, Fault fault) throws Exception {
         org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
         XmlSchemaType schemaType = null;
         Iterator parts = fault.getMessage().getParts().values().iterator();
-        
+
         if (!parts.hasNext()) {
-            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() 
+            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart()
                 + " UNSUPPORTED_FAULT.";
-            org.apache.cxf.common.i18n.Message msg = 
+            org.apache.cxf.common.i18n.Message msg =
                 new org.apache.cxf.common.i18n.Message(msgStr, LOG);
-            throw new Exception(msg.toString());            
+            throw new Exception(msg.toString());
         }
 
         Part part = (Part)parts.next();
@@ -630,7 +619,7 @@ public class WSDLToCorbaBinding {
             if (!helper.isSchemaTypeException(schemaType)) {
                 corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
                 String faultName = fault.getMessage().getQName().getLocalPart();
-                int pos = faultName.indexOf("_exception.");             
+                int pos = faultName.indexOf("_exception.");
                 if (pos != -1) {
                     faultName = faultName.substring(pos + 11);
                     faultName = faultName + "Exception";
@@ -638,7 +627,7 @@ public class WSDLToCorbaBinding {
                 QName faultMsgName = helper.createQNameCorbaNamespace(faultName);
                 corbaex.setName(faultName);
                 corbaex.setQName(faultMsgName);
-                CorbaTypeImpl corbaTypeImpl = 
+                CorbaTypeImpl corbaTypeImpl =
                     helper.convertSchemaToCorbaType(schemaType, name, null, null, false);
                 if (corbaTypeImpl != null) {
                     MemberType member = new MemberType();
@@ -654,30 +643,30 @@ public class WSDLToCorbaBinding {
             }
         }
         if (schemaType == null) {
-            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() 
+            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart()
                  + " INCORRECT_FAULT_MSG.";
-            org.apache.cxf.common.i18n.Message msg = 
+            org.apache.cxf.common.i18n.Message msg =
                 new org.apache.cxf.common.i18n.Message(msgStr, LOG);
-            throw new Exception(msg.toString());                           
+            throw new Exception(msg.toString());
         }
 
         if (corbaex == null) {
-            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() 
+            String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart()
                 + " UNSUPPORTED_FAULT.";
-            org.apache.cxf.common.i18n.Message msg = 
+            org.apache.cxf.common.i18n.Message msg =
                 new org.apache.cxf.common.i18n.Message(msgStr, LOG);
-            throw new Exception(msg.toString());            
+            throw new Exception(msg.toString());
         } else {
             // Set the repository ID for Exception
             // add to CorbaTypeMapping
-            String repoId = WSDLToCorbaHelper.REPO_STRING 
-                + corbaex.getName().replace('.', '/') 
+            String repoId = WSDLToCorbaHelper.REPO_STRING
+                + corbaex.getName().replace('.', '/')
                 + WSDLToCorbaHelper.IDL_VERSION;
             corbaex.setRepositoryID(repoId);
             CorbaTypeImpl corbaTypeImpl = (CorbaTypeImpl)corbaex;
             if (!helper.isDuplicate(corbaTypeImpl)) {
-                CorbaTypeImpl dup = helper.isDuplicateException(corbaTypeImpl);               
-                if (dup != null) {                    
+                CorbaTypeImpl dup = helper.isDuplicateException(corbaTypeImpl);
+                if (dup != null) {
                     typeMappingType.getStructOrExceptionOrUnion().remove(dup);
                     typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
                 } else {
@@ -687,7 +676,7 @@ public class WSDLToCorbaBinding {
         }
         return corbaex;
     }
-    
+
     private org.apache.cxf.binding.corba.wsdl.Exception createCorbaException(QName schemaTypeName,
                                                                                   XmlSchemaType stype)
         throws Exception {
@@ -707,13 +696,13 @@ public class WSDLToCorbaBinding {
                                     + defaultName.getLocalPart()
                                     + WSDLToCorbaHelper.IDL_VERSION);
             String uri = defaultName.getNamespaceURI();
-            List attributeMembers = helper.processAttributesAsMembers(complex.getAttributes().getIterator(),
+            List attributeMembers = helper.processAttributesAsMembers(complex.getAttributes(),
                                                                       uri);
             Iterator iterator = attributeMembers.iterator();
             while (iterator.hasNext()) {
                 MemberType memberType = (MemberType)iterator.next();
                 corbaex.getMember().add(memberType);
-            }            
+            }
             List members = helper.processContainerAsMembers(complex.getParticle(),
                                                             stype.getQName(),
                                                             defaultName);
@@ -721,13 +710,13 @@ public class WSDLToCorbaBinding {
             while (it.hasNext()) {
                 MemberType memberType = (MemberType)it.next();
                 corbaex.getMember().add(memberType);
-            }            
-        }        
+            }
+        }
         return corbaex;
     }
-                
 
-    
+
+
     public void setWsdlFile(String file) {
         wsdlFileName = new String(file);
     }
@@ -737,7 +726,7 @@ public class WSDLToCorbaBinding {
     }
 
     public void setIdlNamespace(Definition definition) {
-            
+
         if (idlNamespace == null) {
             String tns = definition.getTargetNamespace();
             if (!tns.endsWith("/")) {
@@ -771,7 +760,7 @@ public class WSDLToCorbaBinding {
         }
         def.addNamespace(pfx, namespaceURI);
     }
-    
+
 
     public void setBindingName(String bname) {
         bindingName = bname;
@@ -829,33 +818,33 @@ public class WSDLToCorbaBinding {
             if (!fileOutputDir.exists()) {
                 fileOutputDir.mkdir();
             }
-        }    
+        }
     }
 
     public void setExtensionRegistry(ExtensionRegistry reg) {
         extReg = reg;
     }
-    
+
     public ExtensionRegistry getExtensionRegistry() {
         return extReg;
     }
 
     public void setAddress(String addr) {
         address = addr;
-    } 
-    
+    }
+
     public String getAddress() {
         return address;
     }
-    
+
     public void setAddressFile(String addrFile) {
-        addressFile = addrFile;    
+        addressFile = addrFile;
     }
-    
+
     public String getAddressFile() {
         return addressFile;
     }
-    
+
     public void setOutputFile(String file) {
         outputFile = new String(file);
     }
@@ -872,15 +861,15 @@ public class WSDLToCorbaBinding {
     public List getInterfaceNames() {
         return interfaceNames;
     }
-    
+
     public void setVerboseOn(boolean verbose) {
         verboseOn = verbose;
     }
-    
+
     public void setAllBindings(boolean all) {
         allbindings = all;
     }
-    
+
     public boolean isGenerateAllBindings() {
         return allbindings;
     }



Mime
View raw message