tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramku...@apache.org
Subject svn commit: r801108 - /tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
Date Wed, 05 Aug 2009 09:46:31 GMT
Author: ramkumar
Date: Wed Aug  5 09:46:30 2009
New Revision: 801108

URL: http://svn.apache.org/viewvc?rev=801108&view=rev
Log:
Fixes for TUSCANY-2906 - resolve xsd:imports by namespace

Modified:
    tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java

Modified: tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java?rev=801108&r1=801107&r2=801108&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
Wed Aug  5 09:46:30 2009
@@ -37,6 +37,7 @@
 import org.apache.tuscany.sca.xsd.DefaultXSDFactory;
 import org.apache.tuscany.sca.xsd.XSDFactory;
 import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.tuscany.sca.xsd.impl.XSDefinitionImpl;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaInclude;
@@ -314,7 +315,24 @@
                     url = new URL(new URL(baseUri), schemaLocation);
                 }
                 return XMLDocumentHelper.getInputSource(url);
-            } catch (IOException e) {
+            } catch (IOException e) {               
+            	// If we are not able to resolve the imports using location, then 
+            	// try resolving them using the namespace.
+            	try {
+	                for (Artifact artifact : contribution.getArtifacts()) {
+	        			if (artifact.getModel() instanceof XSDefinitionImpl) {
+	        				String artifactNamespace = ((XSDefinitionImpl)artifact.getModel()).getNamespace();
+	        				if (targetNamespace.equals(artifactNamespace)) {
+	        					URL artifactLocation = ((XSDefinitionImpl)artifact.getModel()).getLocation().toURL();
           					
+	        					return XMLDocumentHelper.getInputSource(artifactLocation);
+	        				}
+	        			}
+	        	    }
+                } catch (IOException ex) {
+                	// Invalid URI; return a default InputSource so that the
+                    // XmlSchema code will produce a useful diagnostic
+                    return new InputSource(schemaLocation);
+                }
                 // Invalid URI; return a default InputSource so that the
                 // XmlSchema code will produce a useful diagnostic
                 return new InputSource(schemaLocation);



Mime
View raw message