com.sun.org.apache.xml.internal.resolver.helpers.PublicId Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.resolver.helpers.PublicId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Catalog.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #2
Source File: Catalog.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #3
Source File: Catalog.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #4
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #5
Source File: Catalog.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #6
Source File: Catalog.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #7
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #8
Source File: Catalog.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #9
Source File: Catalog.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #10
Source File: Catalog.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #11
Source File: Catalog.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #12
Source File: Catalog.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #13
Source File: Catalog.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #14
Source File: Catalog.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #15
Source File: Catalog.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #16
Source File: Catalog.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #17
Source File: Catalog.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #18
Source File: Catalog.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #19
Source File: Catalog.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Return the applicable SYSTEM system identifier.
 *
 * <p>If a SYSTEM entry exists in the Catalog
 * for the system ID specified, return the mapped value.</p>
 *
 * <p>On Windows-based operating systems, the comparison between
 * the system identifier provided and the SYSTEM entries in the
 * Catalog is case-insensitive.</p>
 *
 * @param systemId The system ID to locate in the catalog.
 *
 * @return The resolved system identifier.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveSystem("+systemId+")");

  systemId = normalizeURI(systemId);

  if (systemId != null && systemId.startsWith("urn:publicid:")) {
    systemId = PublicId.decodeURN(systemId);
    return resolvePublic(systemId, null);
  }

  // If there's a SYSTEM entry in this catalog, use it
  if (systemId != null) {
    String resolved = resolveLocalSystem(systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(SYSTEM,
                                    null,
                                    null,
                                    systemId);
}
 
Example #20
Source File: Catalog.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Return the applicable URI.
 *
 * <p>If a URI entry exists in the Catalog
 * for the URI specified, return the mapped value.</p>
 *
 * <p>URI comparison is case sensitive.</p>
 *
 * @param uri The URI to locate in the catalog.
 *
 * @return The resolved URI.
 *
 * @throws MalformedURLException The system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveURI(String uri)
  throws MalformedURLException, IOException {

  catalogManager.debug.message(3, "resolveURI("+uri+")");

  uri = normalizeURI(uri);

  if (uri != null && uri.startsWith("urn:publicid:")) {
    uri = PublicId.decodeURN(uri);
    return resolvePublic(uri, null);
  }

  // If there's a URI entry in this catalog, use it
  if (uri != null) {
    String resolved = resolveLocalURI(uri);
    if (resolved != null) {
      return resolved;
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(URI,
                                    null,
                                    null,
                                    uri);
}
 
Example #21
Source File: Catalog.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable ENTITY system identifier.
 *
 * @param entityName The name of the entity for which
 * a system identifier is required.
 * @param publicId The nominal public identifier for the entity
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the entity
 * (as provided in the source document).
 *
 * @return The system identifier to use for the entity.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveEntity(String entityName,
                            String publicId,
                            String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveEntity("
                +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(ENTITY,
                                  entityName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a ENTITY 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() == ENTITY
        && e.getEntryArg(0).equals(entityName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(ENTITY,
                                    entityName,
                                    publicId,
                                    systemId);
}
 
Example #22
Source File: XCatalogReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The SAX <code>startElement</code> method recognizes elements
 * from the plain catalog format and instantiates CatalogEntry
 * objects for them.
 *
 * @param namespaceURI The namespace name of the element.
 * @param localName The local name of the element.
 * @param qName The QName of the element.
 * @param atts The list of attributes on the element.
 *
 * @see CatalogEntry
 */
public void startElement (String namespaceURI,
                          String localName,
                          String qName,
                          Attributes atts)
  throws SAXException {

  int entryType = -1;
  Vector entryArgs = new Vector();

  if (localName.equals("Base")) {
    entryType = catalog.BASE;
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Base", atts.getValue("HRef"));
  } else if (localName.equals("Delegate")) {
    entryType = catalog.DELEGATE_PUBLIC;
    entryArgs.add(atts.getValue("PublicId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Delegate",
                  PublicId.normalize(atts.getValue("PublicId")),
                  atts.getValue("HRef"));
  } else if (localName.equals("Extend")) {
    entryType = catalog.CATALOG;
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Extend", atts.getValue("HRef"));
  } else if (localName.equals("Map")) {
    entryType = catalog.PUBLIC;
    entryArgs.add(atts.getValue("PublicId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Map",
                  PublicId.normalize(atts.getValue("PublicId")),
                  atts.getValue("HRef"));
  } else if (localName.equals("Remap")) {
    entryType = catalog.SYSTEM;
    entryArgs.add(atts.getValue("SystemId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Remap",
                  atts.getValue("SystemId"),
                  atts.getValue("HRef"));
  } else if (localName.equals("XMLCatalog")) {
    // nop, start of catalog
  } else {
    // This is equivalent to an invalid catalog entry type
    catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
  }

  if (entryType >= 0) {
    try {
      CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
      catalog.addEntry(ce);
    } catch (CatalogException cex) {
      if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
        catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
      } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
        catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", localName);
      }
    }
  }
  }
 
Example #23
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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.
 */
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);
}
 
Example #24
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable ENTITY system identifier.
 *
 * @param entityName The name of the entity for which
 * a system identifier is required.
 * @param publicId The nominal public identifier for the entity
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the entity
 * (as provided in the source document).
 *
 * @return The system identifier to use for the entity.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveEntity(String entityName,
                            String publicId,
                            String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveEntity("
                +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(ENTITY,
                                  entityName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a ENTITY 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() == ENTITY
        && e.getEntryArg(0).equals(entityName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(ENTITY,
                                    entityName,
                                    publicId,
                                    systemId);
}
 
Example #25
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable NOTATION system identifier.
 *
 * @param notationName The name of the notation for which
 * a doctype is required.
 * @param publicId The nominal public identifier for the notation
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the notation
 * (as provided in the source document).
 *
 * @return The system identifier to use for the notation.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveNotation(String notationName,
                              String publicId,
                              String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveNotation("
                +notationName+","+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(NOTATION,
                                  notationName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a NOTATION 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() == NOTATION
        && e.getEntryArg(0).equals(notationName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(NOTATION,
                                    notationName,
                                    publicId,
                                    systemId);
}
 
Example #26
Source File: Catalog.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable NOTATION system identifier.
 *
 * @param notationName The name of the notation for which
 * a doctype is required.
 * @param publicId The nominal public identifier for the notation
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the notation
 * (as provided in the source document).
 *
 * @return The system identifier to use for the notation.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveNotation(String notationName,
                              String publicId,
                              String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveNotation("
                +notationName+","+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(NOTATION,
                                  notationName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a NOTATION 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() == NOTATION
        && e.getEntryArg(0).equals(notationName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(NOTATION,
                                    notationName,
                                    publicId,
                                    systemId);
}
 
Example #27
Source File: Catalog.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable ENTITY system identifier.
 *
 * @param entityName The name of the entity for which
 * a system identifier is required.
 * @param publicId The nominal public identifier for the entity
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the entity
 * (as provided in the source document).
 *
 * @return The system identifier to use for the entity.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveEntity(String entityName,
                            String publicId,
                            String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveEntity("
                +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(ENTITY,
                                  entityName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a ENTITY 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() == ENTITY
        && e.getEntryArg(0).equals(entityName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(ENTITY,
                                    entityName,
                                    publicId,
                                    systemId);
}
 
Example #28
Source File: XCatalogReader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The SAX <code>startElement</code> method recognizes elements
 * from the plain catalog format and instantiates CatalogEntry
 * objects for them.
 *
 * @param namespaceURI The namespace name of the element.
 * @param localName The local name of the element.
 * @param qName The QName of the element.
 * @param atts The list of attributes on the element.
 *
 * @see CatalogEntry
 */
public void startElement (String namespaceURI,
                          String localName,
                          String qName,
                          Attributes atts)
  throws SAXException {

  int entryType = -1;
  Vector entryArgs = new Vector();

  if (localName.equals("Base")) {
    entryType = catalog.BASE;
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Base", atts.getValue("HRef"));
  } else if (localName.equals("Delegate")) {
    entryType = catalog.DELEGATE_PUBLIC;
    entryArgs.add(atts.getValue("PublicId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Delegate",
                  PublicId.normalize(atts.getValue("PublicId")),
                  atts.getValue("HRef"));
  } else if (localName.equals("Extend")) {
    entryType = catalog.CATALOG;
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Extend", atts.getValue("HRef"));
  } else if (localName.equals("Map")) {
    entryType = catalog.PUBLIC;
    entryArgs.add(atts.getValue("PublicId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Map",
                  PublicId.normalize(atts.getValue("PublicId")),
                  atts.getValue("HRef"));
  } else if (localName.equals("Remap")) {
    entryType = catalog.SYSTEM;
    entryArgs.add(atts.getValue("SystemId"));
    entryArgs.add(atts.getValue("HRef"));

    catalog.getCatalogManager().debug.message(4, "Remap",
                  atts.getValue("SystemId"),
                  atts.getValue("HRef"));
  } else if (localName.equals("XMLCatalog")) {
    // nop, start of catalog
  } else {
    // This is equivalent to an invalid catalog entry type
    catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
  }

  if (entryType >= 0) {
    try {
      CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
      catalog.addEntry(ce);
    } catch (CatalogException cex) {
      if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
        catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
      } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
        catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", localName);
      }
    }
  }
  }
 
Example #29
Source File: Catalog.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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.
 */
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);
}
 
Example #30
Source File: Catalog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the applicable NOTATION system identifier.
 *
 * @param notationName The name of the notation for which
 * a doctype is required.
 * @param publicId The nominal public identifier for the notation
 * (as provided in the source document).
 * @param systemId The nominal system identifier for the notation
 * (as provided in the source document).
 *
 * @return The system identifier to use for the notation.
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveNotation(String notationName,
                              String publicId,
                              String systemId)
  throws MalformedURLException, IOException {
  String resolved = null;

  catalogManager.debug.message(3, "resolveNotation("
                +notationName+","+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(NOTATION,
                                  notationName,
                                  publicId,
                                  systemId);
    if (resolved != null) {
      return resolved;
    }
  }

  // If there's a NOTATION 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() == NOTATION
        && e.getEntryArg(0).equals(notationName)) {
      if (over || systemId == null) {
        return e.getEntryArg(1);
      }
    }
  }

  // Otherwise, look in the subordinate catalogs
  return resolveSubordinateCatalogs(NOTATION,
                                    notationName,
                                    publicId,
                                    systemId);
}