summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.1/modules/xsd-xml
diff options
context:
space:
mode:
authorramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-08-10 12:13:16 +0000
committerramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-08-10 12:13:16 +0000
commit4155cfcbba228aea45c3bb8842018dbff61ef935 (patch)
treeaa6249879b30ef071375d3b059ea5c3fa9fd992f /branches/sca-java-1.5.1/modules/xsd-xml
parent18f417e28ce1122b8566073e46407f57eaf68066 (diff)
Fixes for TUSCANY-2906 - to resolve wsdl:import and xsd:import using namespace
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@802758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.5.1/modules/xsd-xml')
-rw-r--r--branches/sca-java-1.5.1/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/branches/sca-java-1.5.1/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/branches/sca-java-1.5.1/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
index 51b275d0ae..fb6e8eac20 100644
--- a/branches/sca-java-1.5.1/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
+++ b/branches/sca-java-1.5.1/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
@@ -37,6 +37,7 @@ import org.apache.tuscany.sca.contribution.service.ContributionRuntimeException;
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 @@ public class XSDModelResolver implements ModelResolver {
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);