// Not being very smart about this at the moment. One could, for example,
// see that the schemaLocation or baseUri is the same as another, but differs
// only by a trailing slash. As it is now, we assume a single character difference
// means it's a schema that has yet to be resolved.
schemaKey = Thread.currentThread().getId() + targetNamespace + schemaLocation + baseUri;
SoftReference softref = (SoftReference)resolvedSchemas.get(schemaKey);
if (softref != null) {
XmlSchema resolvedSchema = (XmlSchema)softref.get();
if (resolvedSchema != null) {
return resolvedSchema;
}
}
}
//use the entity resolver provided if the schema location is present null
if (schemaLocation != null && !"".equals(schemaLocation)) {
InputSource source = collection.getSchemaResolver().resolveEntity(
targetNamespace, schemaLocation, baseUri);
//the entity resolver was unable to resolve this!!
if (source == null) {
//try resolving it with the target namespace only with the
//known namespace map
XmlSchema schema = collection.getKnownSchema(targetNamespace);
if (schema != null) {
return schema;
}else{
return null;
}
}
final String systemId = source.getSystemId() == null ? schemaLocation
: source.getSystemId();
// Push repaired system id back into source where read sees it.
// It is perhaps a bad thing to patch the source, but this fixes
// a problem.
source.setSystemId(systemId);
final SchemaKey key = new XmlSchemaCollection.SchemaKey(
targetNamespace, systemId);
XmlSchema schema = collection.getSchema(key);
if (schema != null) {
return schema;
}
if (collection.check(key)) {
collection.push(key);
try {
XmlSchema readSchema = collection.read(source, null, validator);
if (resolvedSchemas != null) {
resolvedSchemas.put(schemaKey, new SoftReference(readSchema));
}
return readSchema;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {