author | thartmann |
Fri, 24 Aug 2018 08:17:23 +0200 | |
changeset 51514 | 1e332d63bd96 |
parent 47216 | 71c04702a3d5 |
child 54342 | 07212a29787a |
permissions | -rw-r--r-- |
33542 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
package javax.xml.catalog; |
|
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 | 33 |
import org.xml.sax.EntityResolver; |
34 |
import org.xml.sax.InputSource; |
|
35 |
||
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. |
45855 | 56 |
* |
40582
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 |
* <h3>Error Handling</h3> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
79 |
* 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
|
80 |
* <ul> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
81 |
* <li> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
82 |
* {@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
|
83 |
* {@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
|
84 |
* </li> |
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 |
* {@link javax.xml.stream.XMLStreamException} by |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
87 |
* {@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
|
88 |
* </li> |
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 |
* {@link javax.xml.transform.TransformerException} by |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
91 |
* {@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
|
92 |
* </li> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
93 |
* </ul> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
94 |
* <p> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
95 |
* 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
|
96 |
* 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
|
97 |
* 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
|
98 |
* 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
|
99 |
* with a {@link javax.xml.catalog.Catalog} object. |
33542 | 100 |
* |
101 |
* @since 9 |
|
102 |
*/ |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
103 |
public interface CatalogResolver extends EntityResolver, XMLResolver, |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
104 |
URIResolver, LSResourceResolver { |
33542 | 105 |
|
106 |
/** |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
107 |
* 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
|
108 |
* 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
|
109 |
* a match with the specified {@code publicId} or systemId. |
33542 | 110 |
* |
111 |
* @param publicId the public identifier of the external entity being |
|
112 |
* referenced, or null if none was supplied |
|
113 |
* |
|
114 |
* @param systemId the system identifier of the external entity being |
|
115 |
* referenced. A system identifier is required on all external entities. XML |
|
116 |
* requires a system identifier on all external entities, so this value is |
|
117 |
* always specified. |
|
118 |
* |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
119 |
* @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
|
120 |
* 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
|
121 |
* 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
|
122 |
* {@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
|
123 |
* returns null if the |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
124 |
* {@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
|
125 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
126 |
* @throws CatalogException if no mapping is found and |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
127 |
* {@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
|
128 |
*/ |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
129 |
@Override |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
130 |
public InputSource resolveEntity(String publicId, String systemId); |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
131 |
|
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 |
* 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
|
135 |
* 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
|
136 |
* 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
|
137 |
* 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
|
138 |
* <p> |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
139 |
* 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
|
140 |
* {@code publicId}, and used to search {@code public} entries. |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
141 |
* 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
|
142 |
* search both {@code system} and {@code uri} entries. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
143 |
* |
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 |
* @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
|
146 |
* which may be relative or absolute |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
147 |
* @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
|
148 |
* absolute if the absolute URI is required |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
149 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
150 |
* @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
|
151 |
* 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
|
152 |
* 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
|
153 |
* {@code ignore}; |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
154 |
* 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
|
155 |
* (href, or href resolved with base if base is not null) if the |
33542 | 156 |
* {@code javax.xml.catalog.resolve} property is set to {@code continue}. |
157 |
* |
|
158 |
* @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
|
159 |
* {@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
|
160 |
*/ |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
161 |
@Override |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
162 |
public Source resolve(String href, String base); |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
163 |
|
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 |
* 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
|
166 |
* {@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
|
167 |
* {@link #resolveEntity(java.lang.String, java.lang.String) }. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
168 |
* <p> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
169 |
* 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
|
170 |
* 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
|
171 |
* 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
|
172 |
* {@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
|
173 |
* 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
|
174 |
* 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
|
175 |
* {@code system} entry. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
176 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
177 |
* @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
|
178 |
* referenced, or null if none was supplied |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
179 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
180 |
* @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
|
181 |
* 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
|
182 |
* 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
|
183 |
* always specified. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
184 |
* @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
|
185 |
* @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
|
186 |
* CatalogResolver. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
187 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
188 |
* @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
|
189 |
* 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
|
190 |
* 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
|
191 |
* 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
|
192 |
* treated the same as {@code continue}. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
193 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
194 |
* @throws CatalogException if no mapping is found and |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
195 |
* {@code javax.xml.catalog.resolve} is specified as {@code strict} |
33542 | 196 |
*/ |
197 |
@Override |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
198 |
public InputStream resolveEntity(String publicId, String systemId, |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
199 |
String baseUri, String namespace); |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
200 |
|
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 |
* 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
|
203 |
* 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
|
204 |
* 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
|
205 |
* <p> |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
206 |
* 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
|
207 |
* 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
|
208 |
* 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
|
209 |
* 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
|
210 |
* 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
|
211 |
* {@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
|
212 |
* recommended over a {@code system} entry. |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
213 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
214 |
* @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
|
215 |
* not used by the CatalogResolver |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
216 |
* @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
|
217 |
* not used by the CatalogResolver |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
218 |
* @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
|
219 |
* 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
|
220 |
* supplied or if the resource is not an entity. |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
221 |
* @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
|
222 |
* external resource being referenced |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
223 |
* @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
|
224 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
225 |
* @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
|
226 |
* 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
|
227 |
* 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
|
228 |
* {@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
|
229 |
* 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
|
230 |
* |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
231 |
* @throws CatalogException if no mapping is found and |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
232 |
* {@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
|
233 |
*/ |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
234 |
@Override |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
235 |
public LSInput resolveResource(String type, String namespaceUri, |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
236 |
String publicId, String systemId, String baseUri); |
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
237 |
|
33542 | 238 |
} |