in xmlresolver-1.2/src/main/java/org/apache/xml/resolver/Catalog.java [1582:1664]
protected synchronized String resolveLocalPublic(int entityType,
String entityName,
String publicId,
String systemId)
throws MalformedURLException, IOException {
// Always normalize the public identifier before attempting a match
publicId = PublicId.normalize(publicId);
// If there's a SYSTEM entry in this catalog, use it
if (systemId != null) {
String resolved = resolveLocalSystem(systemId);
if (resolved != null) {
return resolved;
}
}
// If there's a PUBLIC 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() == PUBLIC
&& e.getEntryArg(0).equals(publicId)) {
if (over || systemId == null) {
return e.getEntryArg(1);
}
}
}
// If there's a DELEGATE_PUBLIC entry in this catalog, use it
over = default_override;
en = catalogEntries.elements();
Vector delCats = new Vector();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == OVERRIDE) {
over = e.getEntryArg(0).equalsIgnoreCase("YES");
continue;
}
if (e.getEntryType() == DELEGATE_PUBLIC
&& (over || systemId == null)) {
String p = (String) e.getEntryArg(0);
if (p.length() <= publicId.length()
&& p.equals(publicId.substring(0, p.length()))) {
// delegate this match to the other catalog
delCats.addElement(e.getEntryArg(1));
}
}
}
if (delCats.size() > 0) {
Enumeration enCats = delCats.elements();
if (catalogManager.debug.getDebug() > 1) {
catalogManager.debug.message(2, "Switching to delegated catalog(s):");
while (enCats.hasMoreElements()) {
String delegatedCatalog = (String) enCats.nextElement();
catalogManager.debug.message(2, "\t" + delegatedCatalog);
}
}
Catalog dcat = newCatalog();
enCats = delCats.elements();
while (enCats.hasMoreElements()) {
String delegatedCatalog = (String) enCats.nextElement();
dcat.parseCatalog(delegatedCatalog);
}
return dcat.resolvePublic(publicId, null);
}
// Nada!
return null;
}