resolved = null;
}
}
} catch (URISyntaxException ex) {
Message msg = new Message("SCHEMA_LOCATION_ERROR_EXC", LOG, location);
throw new ConfigurationException(msg, ex);
}
if (!uri.isAbsolute() && resolved != null && resolved.isAbsolute()) {
uri = resolved;
}
if (uri.isAbsolute()) {
if ("file".equals(uri.getScheme())) {
String path = uri.getPath();
if (null == path) {
Message msg = new Message("FILE_OPEN_ERROR_EXC", LOG, location);
throw new ConfigurationException(msg);
}
File file = new File(path);
if (file.exists()) {
return new InputSource(file.toURI().toString());
}
} else {
//TODO - other protocols like HTTP?
}
}
// uri path is a system resource
URL url = DefaultResourceManager.instance().resolveResource(location, URL.class);
if (null != url) {
return new InputSource(url.toString());
}
//ok, try URL resolving
if (baseURI != null) {
try {
url = new URL(baseURI);
url = new URL(url, location);
InputStream ins = url.openStream();
if (ins != null) {
InputSource src = new InputSource(ins);
src.setSystemId(url.toString());
return src;
}
} catch (MalformedURLException e) {
//ignore
} catch (IOException e) {
//ignore
}
}
/*
System.out.println(baseURI);
System.out.println(location);
System.out.println(uri);
if (baseURI != null) {
System.out.println(base);
System.out.println(resolved);
}
*/
throw new ConfigurationException(new Message("SCHEMA_LOCATION_ERROR_EXC", LOG, location));
}