summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/xsd
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-06 10:27:49 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-06 10:27:49 +0000
commit73ea7b3370913fc111676e1fe82cb27d49d3ad1a (patch)
tree7c787f0ed9b55f76bac7c572b44ed8f5b8e178bb /sca-java-2.x/trunk/modules/xsd
parente481631e3e943ff5cb9abebafaa6a9c2d229e195 (diff)
TUSCANY-3546
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@941644 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/xsd')
-rw-r--r--sca-java-2.x/trunk/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/sca-java-2.x/trunk/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
index 2ae37bc520..b9cb4cde2d 100644
--- a/sca-java-2.x/trunk/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
+++ b/sca-java-2.x/trunk/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
@@ -95,6 +95,15 @@ public class XSDModelResolver implements ModelResolver {
// Lookup a definition for the given namespace, within the contribution
List<XSDefinition> list = map.get(namespace);
+
+ if (list == null ||
+ (list != null && list.size() == 0)){
+ // if no schema is found locally delegate to other
+ // contributions via the imports
+ resolved = resolutionDelegation(namespace, context);
+ return modelClass.cast(resolved);
+ }
+
XSDefinition modelXSD = null;
if (list != null && definition.getDocument() != null) {
// Set the document for the inline schema
@@ -259,6 +268,37 @@ public class XSDModelResolver implements ModelResolver {
return aggregated;
}
+ private XSDefinition resolutionDelegation(String namespace, ProcessorContext context){
+ // Delegate the resolution to namespace imports
+ XSDefinition resolved = null;
+ XSDefinition unresolved = new XSDefinitionImpl();
+ unresolved.setUnresolved(true);
+ unresolved.setNamespace(namespace);
+
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(namespace)) {
+ // Delegate the resolution to the namespace import resolver
+ resolved =
+ namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return resolved;
+ }
+ }
+ } else if (import_ instanceof DefaultImport) {
+ // Delegate the resolution to the default import resolver
+ resolved =
+ import_.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return resolved;
+ }
+ }
+ }
+
+ return resolved;
+ }
+
/**
* URI resolver implementation for XML schema
*/