in xmlresolver-1.2/src/main/java/org/apache/xml/resolver/Catalog.java [1196:1264]
public String resolveDoctype(String entityName,
String publicId,
String systemId)
throws MalformedURLException, IOException {
String resolved = null;
catalogManager.debug.message(3, "resolveDoctype("
+entityName+","+publicId+","+systemId+")");
systemId = normalizeURI(systemId);
if (publicId != null && publicId.startsWith("urn:publicid:")) {
publicId = PublicId.decodeURN(publicId);
}
if (systemId != null && systemId.startsWith("urn:publicid:")) {
systemId = PublicId.decodeURN(systemId);
if (publicId != null && !publicId.equals(systemId)) {
catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
systemId = null;
} else {
publicId = systemId;
systemId = null;
}
}
if (systemId != null) {
// If there's a SYSTEM entry in this catalog, use it
resolved = resolveLocalSystem(systemId);
if (resolved != null) {
return resolved;
}
}
if (publicId != null) {
// If there's a PUBLIC entry in this catalog, use it
resolved = resolveLocalPublic(DOCTYPE,
entityName,
publicId,
systemId);
if (resolved != null) {
return resolved;
}
}
// If there's a DOCTYPE entry in this catalog, use it
boolean over = default_override;
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == OVERRIDE) {
over = e.getEntryArg(0).equalsIgnoreCase("YES");
continue;
}
if (e.getEntryType() == DOCTYPE
&& e.getEntryArg(0).equals(entityName)) {
if (over || systemId == null) {
return e.getEntryArg(1);
}
}
}
// Otherwise, look in the subordinate catalogs
return resolveSubordinateCatalogs(DOCTYPE,
entityName,
publicId,
systemId);
}