summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.3/modules/xsd-xml
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-22 21:16:17 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-22 21:16:17 +0000
commit5e9776cf291d66d2e4789d90957098d3f3fa2386 (patch)
treec40092f1d7d58c1fe590ab0e51420d56a2cc9752 /branches/sca-java-1.3.3/modules/xsd-xml
parent43fb0b55d019f855ae26c88e03a46cb6636e5cfe (diff)
Fix for TUSCANY-2651: Merge the fix from trunk
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@707196 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.3/modules/xsd-xml')
-rw-r--r--branches/sca-java-1.3.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/branches/sca-java-1.3.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/branches/sca-java-1.3.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
index 652d9e8d83..3e22b49d31 100644
--- a/branches/sca-java-1.3.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
+++ b/branches/sca-java-1.3.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
@@ -49,6 +49,7 @@ import org.xml.sax.InputSource;
* @version $Rev$ $Date$
*/
public class XSDModelResolver implements ModelResolver {
+ private static final String AGGREGATED_XSD = "http://tuscany.apache.org/aggregated.xsd";
private XSDFactory factory;
private Contribution contribution;
private Map<String, List<XSDefinition>> map = new HashMap<String, List<XSDefinition>>();
@@ -166,6 +167,12 @@ public class XSDModelResolver implements ModelResolver {
}
// Read an XSD document
InputSource xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL());
+ for (XmlSchema d : schemaCollection.getXmlSchemas()) {
+ if (d.getTargetNamespace().equals(definition.getNamespace())) {
+ if (d.getSourceURI().equals(definition.getLocation().toString()))
+ return;
+ }
+ }
XmlSchema schema = schemaCollection.read(xsd, null);
definition.setSchemaCollection(schemaCollection);
definition.setSchema(schema);
@@ -193,10 +200,25 @@ public class XSDModelResolver implements ModelResolver {
loadOnDemand(d);
}
String ns = definitions.get(0).getNamespace();
- XmlSchema facade = new XmlSchema(ns, schemaCollection);
+
+ XmlSchema facade = null;
+ // Check if the facade XSD is already in the collection
+ for (XmlSchema s : schemaCollection.getXmlSchema(AGGREGATED_XSD)) {
+ if (ns.equals(s.getTargetNamespace())) {
+ facade = s;
+ break;
+ }
+ }
+ if (facade == null) {
+ // This will add the facade into the collection
+ facade = new XmlSchema(ns, AGGREGATED_XSD, schemaCollection);
+ }
for (XmlSchema d : schemaCollection.getXmlSchemas()) {
if (ns.equals(d.getTargetNamespace())) {
+ if (d == facade) {
+ continue;
+ }
XmlSchemaInclude include = new XmlSchemaInclude();
include.setSchema(d);
include.setSourceURI(d.getSourceURI());