Author: ajith
Date: Mon Oct 22 20:05:52 2007
New Revision: 587377

URL: http://svn.apache.org/viewvc?rev=587377&view=rev
Log:
1. The earlier commit made some important tests to fail. Fixing it now

Modified:
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java?rev=587377&r1=587376&r2=587377&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 Mon Oct 22 20:05:52 2007
@@ -137,14 +137,22 @@
         if (element == null){
             //search the imports
             for(Iterator includedItems = 
includes.getIterator();includedItems.hasNext();){
-                  XmlSchemaImport schemaImport = 
(XmlSchemaImport)includedItems.next();
-                 XmlSchema schema  =  schemaImport.getSchema();
-                 if (schema.getElementByName(name)!=null){
-                     return schema.getElementByName(name);
-                 }
+               Object includeOrImport =  includedItems.next();
+                XmlSchema schema = null;
+                if (includeOrImport instanceof XmlSchemaImport){
+                    schema  =  ((XmlSchemaImport)includeOrImport).getSchema();
+                }else if (includeOrImport instanceof XmlSchemaInclude){
+                    schema  =  ((XmlSchemaInclude)includeOrImport).getSchema();
+                }else{
+                    //skip ?
+                    continue;
+                }
+                if (schema.getElementByName(name)!=null){
+                    return schema.getElementByName(name);
+                }
             }
         }else{
-          return element;
+            return element;
         }
 
         return null;
@@ -155,14 +163,23 @@
         if (type == null){
             //search the imports
             for(Iterator includedItems = 
includes.getIterator();includedItems.hasNext();){
-                 XmlSchemaImport schemaImport = 
(XmlSchemaImport)includedItems.next();
-                 XmlSchema schema  =  schemaImport.getSchema();
-                 if (schema.getTypeByName(name)!=null){
-                     return schema.getTypeByName(name);
-                 }
+                Object includeOrImport =  includedItems.next();
+                XmlSchema schema = null;
+                if (includeOrImport instanceof XmlSchemaImport){
+                    schema  =  ((XmlSchemaImport)includeOrImport).getSchema();
+                }else if (includeOrImport instanceof XmlSchemaInclude){
+                    schema  =  ((XmlSchemaInclude)includeOrImport).getSchema();
+                }else{
+                    //skip ?
+                    continue;
+                }
+
+                if (schema.getTypeByName(name)!=null){
+                    return schema.getTypeByName(name);
+                }
             }
         }else{
-          return type;
+            return type;
         }
 
         return null;
@@ -229,7 +246,7 @@
                 write(new OutputStreamWriter(out,this.inputEncoding));
             } catch (UnsupportedEncodingException e) {
                 //log the error and just write it without the encoding
-                
+
                 write(new OutputStreamWriter(out));
             }
         }else{
@@ -247,13 +264,13 @@
         if (this.inputEncoding!= null &&
                 !"".equals(this.inputEncoding)){
             try {
-                 write(new OutputStreamWriter(out,this.inputEncoding),options);
+                write(new OutputStreamWriter(out,this.inputEncoding),options);
             } catch (UnsupportedEncodingException e) {
                 //log the error and just write it without the encoding
                 write(new OutputStreamWriter(out));
             }
         }else{
-             write(new OutputStreamWriter(out),options);
+            write(new OutputStreamWriter(out),options);
         }
 
     }
@@ -425,7 +442,7 @@
 
         return true;
     }
-       public String getInputEncoding() {
-               return inputEncoding;
-       }
+    public String getInputEncoding() {
+        return inputEncoding;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to