jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java
author joehw
Wed, 11 Jan 2017 13:06:04 -0800
changeset 43121 e73af7b6ce47
parent 40582 1dddef49982c
child 45855 46c3f654e80f
permissions -rw-r--r--
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     1
/*
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     4
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    10
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    15
 * accompanied this code).
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    16
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    20
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    23
 * questions.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    24
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    25
package javax.xml.catalog;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    26
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    27
import java.io.InputStream;
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    28
import javax.xml.stream.XMLResolver;
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    29
import javax.xml.transform.Source;
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    30
import javax.xml.transform.URIResolver;
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    31
import org.w3c.dom.ls.LSInput;
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    32
import org.w3c.dom.ls.LSResourceResolver;
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    33
import org.xml.sax.EntityResolver;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    34
import org.xml.sax.InputSource;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    35
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    36
/**
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    37
 * A Catalog Resolver that implements SAX {@link org.xml.sax.EntityResolver},
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    38
 * StAX {@link javax.xml.stream.XMLResolver},
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    39
 * DOM LS {@link org.w3c.dom.ls.LSResourceResolver} used by Schema Validation, and
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    40
 * Transform {@link javax.xml.transform.URIResolver}, and resolves
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    41
 * external references using catalogs.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    42
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    43
 * The <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html">
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    44
 * Catalog Standard</a> distinguished {@code external identifiers} from {@code uri entries}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    45
 * as being used to solely identify DTDs, while {@code uri entries} for
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    46
 * other resources such as stylesheets and schema. The Java APIs, such as
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    47
 * {@link javax.xml.stream.XMLResolver} and {@link org.w3c.dom.ls.LSResourceResolver}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    48
 * however, make no such distinction.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    49
 * In consistent with the existing Java API, this CatalogResolver recognizes a
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    50
 * system identifier as a URI and will search both {@code system} and {@code uri}
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    51
 * entries in a catalog in order to find a matching entry.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    52
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    53
 * The search is started in the current catalog. If a match is found,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    54
 * no further attempt will be made. Only if there is no match in the current
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    55
 * catalog, will alternate catalogs including delegate and next catalogs be considered.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    56
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    57
 * <h3>Search Order</h3>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    58
 * The resolver will first search the system-type of entries with the specified
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    59
 * {@code systemId}. The system entries include {@code system},
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    60
 * {@code rewriteSystem} and {@code systemSuffix} entries.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    61
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    62
 * If no match is found, {@code public} entries may be searched in accordance with
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    63
 * the {@code prefer} attribute.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    64
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    65
 * <b>The {@code prefer} attribute</b>: if the {@code prefer} is public,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    66
 * and there is no match found through the system entries, {@code public} entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    67
 * will be considered. If it is not specified, the {@code prefer} is public
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    68
 * by default (Note that by the OASIS standard, system entries will always
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    69
 * be considered before public entries. Prefer public means that public entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    70
 * will be matched when both system and public identifiers are specified.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    71
 * In general therefore, prefer public is recommended.)
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    72
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    73
 * If no match is found with the {@code systemId} and {@code public} identifier,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    74
 * the resolver will continue searching {@code uri} entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    75
 * with the specified {@code systemId} or {@code href}. The {@code uri} entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    76
 * include {@code uri}, {@code rewriteURI}, and {@code uriSuffix} entries.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    77
 *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    78
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    79
 * <h3>Error Handling</h3>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    80
 * The interfaces that the CatalogResolver extend specified checked exceptions, including:
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    81
 * <ul>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    82
 * <li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    83
 * {@link org.xml.sax.SAXException} and {@link java.io.IOException} by
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    84
 * {@link org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    85
 * </li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    86
 * <li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    87
 * {@link javax.xml.stream.XMLStreamException} by
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    88
 * {@link javax.xml.stream.XMLResolver#resolveEntity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    89
 * </li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    90
 * <li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    91
 * {@link javax.xml.transform.TransformerException} by
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    92
 * {@link javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    93
 * </li>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    94
 * </ul>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    95
 * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    96
 * The CatalogResolver however, will throw {@link javax.xml.catalog.CatalogException}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    97
 * only when {@code javax.xml.catalog.resolve} is specified as {@code strict}.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    98
 * For applications that expect to handle the checked Exceptions, it may be
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
    99
 * necessary to use a custom resolver to wrap the CatalogResolver or implement it
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   100
 * with a {@link javax.xml.catalog.Catalog} object.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   101
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   102
 * @since 9
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   103
 */
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   104
public interface CatalogResolver extends EntityResolver, XMLResolver,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   105
        URIResolver, LSResourceResolver {
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   106
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   107
    /**
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   108
     * Implements {@link org.xml.sax.EntityResolver}. The method searches through
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   109
     * the catalog entries in the main and alternative catalogs to attempt to find
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   110
     * a match with the specified {@code publicId} or systemId.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   111
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   112
     * @param publicId the public identifier of the external entity being
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   113
     * referenced, or null if none was supplied
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   114
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   115
     * @param systemId the system identifier of the external entity being
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   116
     * referenced. A system identifier is required on all external entities. XML
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   117
     * requires a system identifier on all external entities, so this value is
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   118
     * always specified.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   119
     *
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   120
     * @return a {@link org.xml.sax.InputSource} object if a mapping is found.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   121
     * If no mapping is found, returns a {@link org.xml.sax.InputSource} object
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   122
     * containing an empty {@link java.io.Reader} if the
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   123
     * {@code javax.xml.catalog.resolve} property is set to {@code ignore};
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   124
     * returns null if the
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   125
     * {@code javax.xml.catalog.resolve} property is set to {@code continue}.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   126
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   127
     * @throws CatalogException if no mapping is found and
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   128
     * {@code javax.xml.catalog.resolve} is specified as {@code strict}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   129
     */
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   130
    @Override
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   131
    public InputSource resolveEntity(String publicId, String systemId);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   132
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   133
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   134
    /**
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   135
     * Implements URIResolver. The method searches through the catalog entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   136
     * in the main and alternative catalogs to attempt to find a match
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   137
     * with the specified {@code href} attribute. The {@code href} attribute will
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   138
     * be used literally, with no attempt to be made absolute to the {@code base}.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   139
     * <p>
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   140
     * If the value is a URN, the {@code href} attribute is recognized as a
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   141
     * {@code publicId}, and used to search {@code public} entries.
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   142
     * If the value is a URI, it is taken as a {@code systemId}, and used to
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   143
     * search both {@code system} and {@code uri} entries.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   144
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   145
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   146
     * @param href the href attribute that specifies the URI of a style sheet,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   147
     * which may be relative or absolute
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   148
     * @param base The base URI against which the href attribute will be made
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   149
     * absolute if the absolute URI is required
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   150
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   151
     * @return a {@link javax.xml.transform.Source} object if a mapping is found.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   152
     * If no mapping is found, returns an empty {@link javax.xml.transform.Source}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   153
     * object if the {@code javax.xml.catalog.resolve} property is set to
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   154
     * {@code ignore};
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   155
     * returns a {@link javax.xml.transform.Source} object with the original URI
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   156
     * (href, or href resolved with base if base is not null) if the
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   157
     * {@code javax.xml.catalog.resolve} property is set to {@code continue}.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   158
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   159
     * @throws CatalogException if no mapping is found and
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   160
     * {@code javax.xml.catalog.resolve} is specified as {@code strict}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   161
     */
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   162
    @Override
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   163
    public Source resolve(String href, String base);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   164
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   165
    /**
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   166
     * Implements {@link javax.xml.stream.XMLResolver}. For the purpose of resolving
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   167
     * {@code publicId} and {@code systemId}, this method is equivalent to
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   168
     * {@link #resolveEntity(java.lang.String, java.lang.String) }.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   169
     * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   170
     * The {@code systemId} will be used literally, with no attempt to be made
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   171
     * absolute to the {@code baseUri}. The {@code baseUri} and {@code namespace}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   172
     * are not used in the search for a match in a catalog. However, a relative
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   173
     * {@code systemId} in an xml source may have been made absolute by the parser
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   174
     * with the {@code baseURI}, thus making it unable to find a {@code system} entry.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   175
     * In such a case, a {@code systemSuffix} entry is recommended over a
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   176
     * {@code system} entry.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   177
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   178
     * @param publicId the public identifier of the external entity being
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   179
     * referenced, or null if none was supplied
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   180
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   181
     * @param systemId the system identifier of the external entity being
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   182
     * referenced. A system identifier is required on all external entities. XML
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   183
     * requires a system identifier on all external entities, so this value is
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   184
     * always specified.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   185
     * @param baseUri  the absolute base URI, not used by the CatalogResolver
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   186
     * @param namespace the namespace of the entity to resolve, not used by the
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   187
     * CatalogResolver.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   188
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   189
     * @return an {@link java.io.InputStream} object if a mapping is found; null
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   190
     * if no mapping is found and the {@code javax.xml.catalog.resolve} property
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   191
     * is set to {@code continue} or {@code ignore}. Note that for XMLResolver,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   192
     * it is not possible to ignore a reference, {@code ignore} is therefore
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   193
     * treated the same as {@code continue}.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   194
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   195
     * @throws CatalogException if no mapping is found and
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   196
     * {@code javax.xml.catalog.resolve} is specified as {@code strict}
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   197
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   198
    @Override
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   199
    public InputStream resolveEntity(String publicId, String systemId,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   200
            String baseUri, String namespace);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   201
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   202
    /**
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   203
     * Implements {@link org.w3c.dom.ls.LSResourceResolver}. For the purpose of
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   204
     * resolving {@code publicId} and {@code systemId}, this method is equivalent
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   205
     * to {@link #resolveEntity(java.lang.String, java.lang.String) }.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   206
     * <p>
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   207
     * The {@code systemId} will be used literally, with no attempt to be made
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   208
     * absolute to the {@code baseUri}. The {@code baseUri}, {@code namespaceUri}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   209
     * and {@code type} are not used in the search for a match in a catalog.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   210
     * However, a relative {@code systemId} in a source may have been made absolute
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   211
     * by the parser with the {@code baseURI}, thus making it unable to find a
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   212
     * {@code system} entry. In such a case, a {@code systemSuffix} entry is
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   213
     * recommended over a {@code system} entry.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   214
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   215
     * @param type  the type of the resource being resolved,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   216
     * not used by the CatalogResolver
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   217
     * @param namespaceUri  the namespace of the resource being resolved,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   218
     * not used by the CatalogResolver
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   219
     * @param publicId  the public identifier of the external entity being
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   220
     *   referenced, or {@code null} if no public identifier was
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   221
     *   supplied or if the resource is not an entity.
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   222
     * @param systemId  the system identifier, a URI reference of the
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   223
     *   external resource being referenced
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   224
     * @param baseUri  the absolute base URI, not used by the CatalogResolver
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   225
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   226
     * @return a {@link org.w3c.dom.ls.LSInput} object if a mapping is found; null
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   227
     * if no mapping is found and the {@code javax.xml.catalog.resolve} property
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   228
     * is set to {@code continue} or {@code ignore}. Note that for
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   229
     * {@link org.w3c.dom.ls.LSResourceResolver}, it is not possible to ignore a
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   230
     * reference, {@code ignore} is therefore treated the same as {@code continue}.
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   231
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   232
     * @throws CatalogException if no mapping is found and
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   233
     * {@code javax.xml.catalog.resolve} is specified as {@code strict}
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   234
     */
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   235
    @Override
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   236
    public LSInput resolveResource(String type, String namespaceUri,
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   237
            String publicId, String systemId, String baseUri);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 33542
diff changeset
   238
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   239
}