You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/08/08 15:20:40 UTC

svn commit: r429647 - /webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java

Author: dims
Date: Tue Aug  8 06:20:40 2006
New Revision: 429647

URL: http://svn.apache.org/viewvc?rev=429647&view=rev
Log:
fix for AXIS2-987 and AXIS2-963 from Fabian Christ

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java

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?rev=429647&r1=429646&r2=429647&view=diff
==============================================================================
--- 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 Tue Aug  8 06:20:40 2006
@@ -1214,8 +1214,19 @@
                     referencedQName = elt.getRefName();
                     boolean arrayStatus = ((Boolean) processedElementArrayStatusMap.get(elt)).booleanValue();
                     clazzName = findRefClassName(referencedQName,arrayStatus);
+                    XmlSchemaElement refElement = parentSchema.getElementByName(referencedQName);
+                    
+                    if (refElement == null) {
+                        refElement = lookupImportedSchema(parentSchema, referencedQName);
+                    }
+                    
+                    // register the mapping if we found the referenced element
+                    // else throw an exception
+                    if (refElement == null) {
+                        throw new SchemaCompilationException("Referenced element not found!");
+                    }
                     metainfHolder.registerMapping(referencedQName,
-                            parentSchema.getElementByName(referencedQName).getSchemaTypeName()
+                            refElement.getSchemaTypeName()
                             , clazzName,
                             arrayStatus ?
                                     SchemaConstants.ARRAY_TYPE :
@@ -1280,7 +1291,34 @@
         //set the ordered flag in the metainf holder
         metainfHolder.setOrdered(order);
     }
-
+    private XmlSchemaElement lookupImportedSchema(XmlSchema parentSchema, QName referencedQName) {
+        XmlSchemaElement refElement = null;
+        // The referenced element seems to come from an imported
+        // schema.
+        XmlSchemaObjectCollection includes = parentSchema.getIncludes();
+        if (includes != null) {
+            Iterator tempIterator = includes.getIterator();
+            while (tempIterator.hasNext()) {
+                Object o = tempIterator.next();
+                XmlSchema inclSchema = null;
+                if (o instanceof XmlSchemaImport) {
+                    inclSchema = ((XmlSchemaImport) o).getSchema();
+                }
+                if (o instanceof XmlSchemaInclude) {
+                    inclSchema = ((XmlSchemaInclude) o).getSchema();
+                }
+                // get the element from the included schema
+                if (inclSchema != null) {
+                    refElement = inclSchema.getElementByName(referencedQName);
+                }
+                if (refElement != null) {
+                    // we found the referenced element an can break the loop
+                    break;
+                }
+            }
+        }
+        return refElement;
+    }
     /**
      * Checks whether a given element is a binary element
      * @param elt



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