src/main/java/org/jboss/util/xml/catalog/Catalog.java
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 enumt = catalogEntries.elements();
    while (enumt.hasMoreElements()) {
      CatalogEntry e = (CatalogEntry) enumt.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);
  }
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 enumt = catalogEntries.elements();
    while (enumt.hasMoreElements()) {
      CatalogEntry e = (CatalogEntry) enumt.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);
  }
Return the applicable DOCTYPE system identifier.

@param entityName The name of the entity (element) for which
a doctype is required.
@param publicId The nominal public identifier for the doctype
(as provided in the source document).
@param systemId The nominal system identifier for the doctype
(as provided in the source document).

@return The system identifier to use for the doctype.

@throws MalformedURLException The formal system identifier of a
subordinate catalog cannot be turned into a valid URL.
@throws IOException Error reading subordinate catalog file.