// find original cause of the problem
Throwable cause = e;
while (cause.getCause() != null && cause != cause.getCause()) {
cause = cause.getCause();
}
throw new ContributionRuntimeException(cause);
}
definition.setSchemaCollection(schemaCollection);
definition.setSchema(schema);
definition.setUnresolved(false);
} else if (definition.getLocation() != null) {
if (definition.getLocation().getFragment() != null) {
// It's an inline schema
// FIXME: We need to trigger the loading of the enclosing WSDL models
return;
}
// Read an XSD document
XmlSchema schema = null;
for (XmlSchema d : schemaCollection.getXmlSchemas()) {
if (isSameNamespace(d.getTargetNamespace(), definition.getNamespace())) {
if (d.getSourceURI().equals(definition.getLocation().toString())) {
schema = d;
break;
}
}
}
if (schema == null) {
InputSource xsd = null;
try {
xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL());
} catch (IOException e) {
throw new ContributionRuntimeException(e);
}
try {
schema = schemaCollection.read(xsd, null);
} catch (RuntimeException e) {
// find original cause of the problem
Throwable cause = e;
while (cause.getCause() != null && cause != cause.getCause()) {
cause = cause.getCause();
}
throw new ContributionRuntimeException(cause);
}
}
definition.setSchemaCollection(schemaCollection);
definition.setSchema(schema);
}