You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by am...@apache.org on 2007/04/06 07:12:57 UTC

svn commit: r526056 - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/ codegen/src/org/apache/axis2/wsdl/codegen/extension/ kernel/src/org/apache/axis2/description/

Author: amilas
Date: Thu Apr  5 22:12:56 2007
New Revision: 526056

URL: http://svn.apache.org/viewvc?view=rev&rev=526056
Log:
fix for issue 2475

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?view=diff&rev=526056&r1=526055&r2=526056
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java Thu Apr  5 22:12:56 2007
@@ -330,46 +330,21 @@
                     XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
                     boolean isArray = (xmlSchemaElement.getMaxOccurs() - xmlSchemaElement.getMinOccurs()) > 1;
 
-//                    XmlSchemaType eltSchemaType = xmlSchemaElement.getSchemaType();
-//                    if (eltSchemaType != null) {
-//                        //there is a schema type object.We can utilize that
-//                        populateClassName(eltSchemaType.getMetaInfoMap(),
-//                                mapper,
-//                                opName,
-//                                isArray,
-//                                xmlSchemaElement.getName(),
-//                                qnameSuffix);
-//                    } else if (xmlSchemaElement.getSchemaTypeName() != null) {
-//                        //there is no schema type object but there is a
-//                        //schema type QName.  Use that Qname to look up the
-//                        //schematype in other schema objects
-//                        eltSchemaType = findSchemaType(schemaMap,
-//                                xmlSchemaElement.getSchemaTypeName());
-//                        if (eltSchemaType != null) {
-//                            populateClassName(eltSchemaType.getMetaInfoMap(),
-//                                    mapper,
-//                                    opName,
-//                                    isArray,
-//                                    xmlSchemaElement.getName(),
-//                                    qnameSuffix);
-//                        } else if (xmlSchemaElement.getSchemaTypeName().equals(SchemaConstants.XSD_ANYTYPE)) {
-//                            QName partQName = WSDLUtil.getPartQName(opName,
-//                                    qnameSuffix,
-//                                    xmlSchemaElement.getName());
-//
-//                            if (xmlSchemaElement.getMaxOccurs() > 1) {
-//                                mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement[]");
-//                            } else {
-//                                mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement");
-//                            }
-//                        }
-//                    }
+                    XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
+                    String partName = null;
+                    if (xmlSchemaElement.getRefName() != null) {
+                        partName = xmlSchemaElement.getRefName().getLocalPart();
+                    } else {
+                        partName = xmlSchemaElement.getName();
+                    }
+
+
                     // get the element class name from the element and populate the mapper
                     populateClassName(xmlSchemaElement.getMetaInfoMap(),
                                     mapper,
                                     opName,
                                     isArray,
-                                    xmlSchemaElement.getName(),
+                                    partName,
                                     qnameSuffix);
                 } else if (item instanceof XmlSchemaAny) {
 

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?view=diff&rev=526056&r1=526055&r2=526056
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Thu Apr  5 22:12:56 2007
@@ -1595,21 +1595,34 @@
             QName attributeQName = att.getQName();
             if (attributeQName != null) {
                 XmlSchemaSimpleType attributeSimpleType = att.getSchemaType();
-                QName schemaTypeQName = att.getSchemaTypeName();
-                if (schemaTypeQName == null) {
-                    // set the parent schema target name space since attribute Qname uri is ""
-                    schemaTypeQName = new QName(parentSchema.getTargetNamespace(), attributeQName.getLocalPart() + getNextTypeSuffix());
+                if (attributeSimpleType == null) {
+                    // try to get the schema for using qname
+                    QName attributeSchemaQname = att.getSchemaTypeName();
+                    if (attributeSchemaQname != null) {
+                        attributeSimpleType = (XmlSchemaSimpleType) getType(parentSchema, attributeSchemaQname);
+                    }
                 }
-                processSimpleSchemaType(attributeSimpleType, null, parentSchema, schemaTypeQName);
-                metainf.registerMapping(att.getQName(),
-                        schemaTypeQName,
-                        processedTypemap.get(schemaTypeQName).toString(),
-                        SchemaConstants.ATTRIBUTE_TYPE);
-                // add optional attribute status if set
-                String use = att.getUse().getValue();
-                if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
-                    metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
+
+                if (attributeSimpleType != null) {
+                    QName schemaTypeQName = att.getSchemaTypeName();
+                    if (schemaTypeQName == null) {
+                        // set the parent schema target name space since attribute Qname uri is ""
+                        schemaTypeQName = new QName(parentSchema.getTargetNamespace(), attributeQName.getLocalPart() + getNextTypeSuffix());
+                    }
+                    processSimpleSchemaType(attributeSimpleType, null, parentSchema, schemaTypeQName);
+                    metainf.registerMapping(att.getQName(),
+                            schemaTypeQName,
+                            processedTypemap.get(schemaTypeQName).toString(),
+                            SchemaConstants.ATTRIBUTE_TYPE);
+                    // add optional attribute status if set
+                    String use = att.getUse().getValue();
+                    if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
+                        metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
+                    }
+                } else {
+                    // TODO: handle the case when no attribute type specifed
                 }
+
             }
 
         }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java?view=diff&rev=526056&r1=526055&r2=526056
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java Thu Apr  5 22:12:56 2007
@@ -279,7 +279,14 @@
                 // traverse through them
                 if (item instanceof XmlSchemaElement) {
                     //add the element name to the part name list
-                    String partName = ((XmlSchemaElement)item).getName();
+                    XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
+                    XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
+                    String partName = null;
+                    if (xmlSchemaElement.getRefName() != null) {
+                        partName = xmlSchemaElement.getRefName().getLocalPart();
+                    } else {
+                        partName = xmlSchemaElement.getName();
+                    }
 
                     //  part names are not unique across messages. Hence
                     //  we need some way of making the part name a unique

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?view=diff&rev=526056&r1=526055&r2=526056
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Thu Apr  5 22:12:56 2007
@@ -20,8 +20,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.*;
 
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
@@ -99,24 +98,40 @@
     }
 
     public XmlSchemaElement getSchemaElement() {
+        XmlSchemaElement xmlSchemaElement = null;
         AxisService service = (AxisService) getParent().getParent();
         ArrayList schemas = service.getSchema();
-        for (int i = 0; i < schemas.size(); i++) {
-            XmlSchema schema = (XmlSchema) schemas.get(i);
-            if (schema.getItems() != null) {
-                Iterator schemaItems = schema.getItems().getIterator();
-                while (schemaItems.hasNext()) {
-                    Object item = schemaItems.next();
-                    if (item instanceof XmlSchemaElement) {
-                        XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
-                        if (xmlSchemaElement.getQName().equals(this.elementQname)) {
-                            return xmlSchemaElement;
+        for (Iterator schemaIter = schemas.iterator(); schemaIter.hasNext();){
+            xmlSchemaElement = getSchemaElement((XmlSchema) schemaIter.next());
+        }
+        return xmlSchemaElement;
+    }
+
+    private XmlSchemaElement getSchemaElement(XmlSchema schema) {
+        XmlSchemaElement xmlSchemaElement = null;
+        if (schema != null) {
+            xmlSchemaElement = schema.getElementByName(this.elementQname);
+            if (xmlSchemaElement == null) {
+                // try to find in an import or an include
+                XmlSchemaObjectCollection includes = schema.getIncludes();
+                if (includes != null) {
+                    Iterator includesIter = includes.getIterator();
+                    Object object = null;
+                    while (includesIter.hasNext()) {
+                        object = includesIter.next();
+                        if (object instanceof XmlSchemaImport) {
+                            XmlSchema schema1 = ((XmlSchemaImport) object).getSchema();
+                            xmlSchemaElement = getSchemaElement(schema1);
+                        }
+                        if (object instanceof XmlSchemaInclude) {
+                            XmlSchema schema1 = ((XmlSchemaInclude) object).getSchema();
+                            xmlSchemaElement = getSchemaElement(schema1);
                         }
                     }
                 }
             }
         }
-        return null;
+        return xmlSchemaElement;
     }
 
     public String getName() {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org