-
- All Superinterfaces:
EntityResolver
,LSResourceResolver
,URIResolver
,XMLResolver
public interface CatalogResolver extends EntityResolver, XMLResolver, URIResolver, LSResourceResolver
A Catalog Resolver that implements SAXEntityResolver
, StAXXMLResolver
, DOM LSLSResourceResolver
used by Schema Validation, and TransformURIResolver
, and resolves external references using catalogs.The Catalog Standard distinguished
external identifiers
fromuri entries
as being used to solely identify DTDs, whileuri entries
for other resources such as stylesheets and schema. The Java APIs, such asXMLResolver
andLSResourceResolver
however, make no such distinction. In consistent with the existing Java API, this CatalogResolver recognizes a system identifier as a URI and will search bothsystem
anduri
entries in a catalog in order to find a matching entry.The search is started in the current catalog. If a match is found, no further attempt will be made. Only if there is no match in the current catalog, will alternate catalogs including delegate and next catalogs be considered.
Search Order
The resolver will first search the system-type of entries with the specifiedsystemId
. The system entries includesystem
,rewriteSystem
andsystemSuffix
entries.If no match is found,
public
entries may be searched in accordance with theprefer
attribute.The
prefer
attribute: if theprefer
is public, and there is no match found through the system entries,public
entries will be considered. If it is not specified, theprefer
is public by default (Note that by the OASIS standard, system entries will always be considered before public entries. Prefer public means that public entries will be matched when both system and public identifiers are specified. In general therefore, prefer public is recommended.)If no match is found with the
systemId
andpublic
identifier, the resolver will continue searchinguri
entries with the specifiedsystemId
orhref
. Theuri
entries includeuri
,rewriteURI
, anduriSuffix
entries.Error Handling
The interfaces that the CatalogResolver extend specified checked exceptions, including:-
SAXException
andIOException
byEntityResolver.resolveEntity(java.lang.String, java.lang.String)
-
XMLStreamException
byXMLResolver.resolveEntity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
TransformerException
byURIResolver.resolve(java.lang.String, java.lang.String)
The CatalogResolver however, will throw
CatalogException
only whenjavax.xml.catalog.resolve
is specified asstrict
. For applications that expect to handle the checked Exceptions, it may be necessary to use a custom resolver to wrap the CatalogResolver or implement it with aCatalog
object.- Since:
- 9
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Source
resolve(String href, String base)
Implements URIResolver.InputSource
resolveEntity(String publicId, String systemId)
ImplementsEntityResolver
.InputStream
resolveEntity(String publicId, String systemId, String baseUri, String namespace)
ImplementsXMLResolver
.LSInput
resolveResource(String type, String namespaceUri, String publicId, String systemId, String baseUri)
ImplementsLSResourceResolver
.
-
-
-
Method Detail
-
resolveEntity
InputSource resolveEntity(String publicId, String systemId)
ImplementsEntityResolver
. The method searches through the catalog entries in the main and alternative catalogs to attempt to find a match with the specifiedpublicId
or systemId.- Specified by:
resolveEntity
in interfaceEntityResolver
- Parameters:
publicId
- the public identifier of the external entity being referenced, or null if none was suppliedsystemId
- the system identifier of the external entity being referenced. A system identifier is required on all external entities. XML requires a system identifier on all external entities, so this value is always specified.- Returns:
- a
InputSource
object if a mapping is found. If no mapping is found, returns aInputSource
object containing an emptyReader
if thejavax.xml.catalog.resolve
property is set toignore
; returns null if thejavax.xml.catalog.resolve
property is set tocontinue
. - Throws:
CatalogException
- if no mapping is found andjavax.xml.catalog.resolve
is specified asstrict
- See Also:
InputSource
-
resolve
Source resolve(String href, String base)
Implements URIResolver. The method searches through the catalog entries in the main and alternative catalogs to attempt to find a match with the specifiedhref
attribute. Thehref
attribute will be used literally, with no attempt to be made absolute to thebase
.If the value is a URN, the
href
attribute is recognized as apublicId
, and used to searchpublic
entries. If the value is a URI, it is taken as asystemId
, and used to search bothsystem
anduri
entries.- Specified by:
resolve
in interfaceURIResolver
- Parameters:
href
- the href attribute that specifies the URI of a style sheet, which may be relative or absolutebase
- The base URI against which the href attribute will be made absolute if the absolute URI is required- Returns:
- a
Source
object if a mapping is found. If no mapping is found, returns an emptySource
object if thejavax.xml.catalog.resolve
property is set toignore
; returns aSource
object with the original URI (href, or href resolved with base if base is not null) if thejavax.xml.catalog.resolve
property is set tocontinue
. - Throws:
CatalogException
- if no mapping is found andjavax.xml.catalog.resolve
is specified asstrict
-
resolveEntity
InputStream resolveEntity(String publicId, String systemId, String baseUri, String namespace)
ImplementsXMLResolver
. For the purpose of resolvingpublicId
andsystemId
, this method is equivalent toresolveEntity(java.lang.String, java.lang.String)
.The
systemId
will be used literally, with no attempt to be made absolute to thebaseUri
. ThebaseUri
andnamespace
are not used in the search for a match in a catalog. However, a relativesystemId
in an xml source may have been made absolute by the parser with thebaseURI
, thus making it unable to find asystem
entry. In such a case, asystemSuffix
entry is recommended over asystem
entry.- Specified by:
resolveEntity
in interfaceXMLResolver
- Parameters:
publicId
- the public identifier of the external entity being referenced, or null if none was suppliedsystemId
- the system identifier of the external entity being referenced. A system identifier is required on all external entities. XML requires a system identifier on all external entities, so this value is always specified.baseUri
- the absolute base URI, not used by the CatalogResolvernamespace
- the namespace of the entity to resolve, not used by the CatalogResolver.- Returns:
- an
InputStream
object if a mapping is found; null if no mapping is found and thejavax.xml.catalog.resolve
property is set tocontinue
orignore
. Note that for XMLResolver, it is not possible to ignore a reference,ignore
is therefore treated the same ascontinue
. - Throws:
CatalogException
- if no mapping is found andjavax.xml.catalog.resolve
is specified asstrict
-
resolveResource
LSInput resolveResource(String type, String namespaceUri, String publicId, String systemId, String baseUri)
ImplementsLSResourceResolver
. For the purpose of resolvingpublicId
andsystemId
, this method is equivalent toresolveEntity(java.lang.String, java.lang.String)
.The
systemId
will be used literally, with no attempt to be made absolute to thebaseUri
. ThebaseUri
,namespaceUri
andtype
are not used in the search for a match in a catalog. However, a relativesystemId
in a source may have been made absolute by the parser with thebaseURI
, thus making it unable to find asystem
entry. In such a case, asystemSuffix
entry is recommended over asystem
entry.- Specified by:
resolveResource
in interfaceLSResourceResolver
- Parameters:
type
- the type of the resource being resolved, not used by the CatalogResolvernamespaceUri
- the namespace of the resource being resolved, not used by the CatalogResolverpublicId
- the public identifier of the external entity being referenced, ornull
if no public identifier was supplied or if the resource is not an entity.systemId
- the system identifier, a URI reference of the external resource being referencedbaseUri
- the absolute base URI, not used by the CatalogResolver- Returns:
- a
LSInput
object if a mapping is found; null if no mapping is found and thejavax.xml.catalog.resolve
property is set tocontinue
orignore
. Note that forLSResourceResolver
, it is not possible to ignore a reference,ignore
is therefore treated the same ascontinue
. - Throws:
CatalogException
- if no mapping is found andjavax.xml.catalog.resolve
is specified asstrict
-
-