Returns an InputSource for the requested DTD or schema.
This implementation returns an InputSource that wraps the result
of getResourceAsStream, having
located the requested schema in the classpath.
InputSource result = null;
/*
*This logic was patterned after that in the superclass.
*/
try {
if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
DOLUtils.getDefaultLogger().fine("Asked to resolve " + publicID + " system id = " + systemID);
}
if (publicID==null) {
// unspecified schema
if (systemID==null || systemID.lastIndexOf('/")==systemID.length()) {
return null;
}
/*
*Attempt to open a stream to the requested resource as a schema.
*/
InputStream is = openSchemaStream(systemID);
if (is != null) {
/*
*We found the entity, so wrap an InputSource around the stream.
*/
result = new InputSource(is);
} else {
/*
*The entity was not found, so wrap an InputSource around the system ID string instead.
*/
result = new InputSource(systemID);
}
} else {
/*
*Try to find a DTD for the entity.
*/
if ( getMapping().containsKey(publicID)) {
this.publicID = publicID;
InputStream is = openDTDStream(publicID);
if (is != null) {
result = new InputSource(is);
}
} else if (systemID != null) {
/*
*The DTD lookup failed but a system ID was also specified. Try
*looking up the DTD in the schemas path, because some reside
*there and were not registered in the DTD map by SaxParserHandler.
*/
InputStream is = openSchemaStream(systemID);
if (is != null) {
result = new InputSource(is);
}
}
}
} catch (Exception exc) {
exc.printStackTrace();
throw new SAXException(exc);
}
return result;