T
- The type of the feature.public class ResolverFeature<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static ResolverFeature<java.lang.Boolean> |
ALLOW_CATALOG_PI
Determines whether or not the catalog PI in a document
may change the list of catalog files to be consulted.
|
static ResolverFeature<java.lang.Boolean> |
ARCHIVED_CATALOGS
Adds support for placing ZIP files on the catalog path.
|
static ResolverFeature<ResourceCache> |
CACHE
Provides access to the
ResourceCache that the resolver is using. |
static ResolverFeature<java.lang.String> |
CACHE_DIRECTORY
Sets the location of the cache directory.
|
static ResolverFeature<java.lang.Boolean> |
CACHE_UNDER_HOME
Determines if a default cache location of
.xmlresolver.org/cache
under the users home directory should be used for the cache. |
static ResolverFeature<java.util.List<java.lang.String>> |
CATALOG_ADDITIONS
Sets the list of additional catalog files.
|
static ResolverFeature<java.util.List<java.lang.String>> |
CATALOG_FILES
Sets the list of catalog files.
|
static ResolverFeature<java.lang.String> |
CATALOG_LOADER_CLASS
Identifies the catalog loader class.
|
static ResolverFeature<CatalogManager> |
CATALOG_MANAGER
Provides access to the
CatalogManager that
the resolver is using. |
static ResolverFeature<java.lang.ClassLoader> |
CLASSLOADER
Identify the ClassLoader to use for accessing resources on the classpath.
|
static ResolverFeature<java.lang.Boolean> |
CLASSPATH_CATALOGS
Determines whether or not catalogs on the classpath should be loaded automatically.
|
static ResolverFeature<java.lang.Boolean> |
MASK_JAR_URIS
Determines whether a classpath: or jar: URI is returned by the resolver.
|
static ResolverFeature<java.lang.Boolean> |
MERGE_HTTPS
Determines whether http: and https: URIs compare the same.
|
static ResolverFeature<java.lang.Boolean> |
PARSE_RDDL
Controls whether or not namespace documents will be parsed for RDDL annotations.
|
static ResolverFeature<java.lang.Boolean> |
PREFER_PROPERTY_FILE
Determines whether property file values are preferred over
system property values.
|
static ResolverFeature<java.lang.Boolean> |
PREFER_PUBLIC
Determines whether or not public IDs are preferred..
|
static ResolverFeature<java.lang.Boolean> |
URI_FOR_SYSTEM
Determines whether or not
uri catalog entries
can be used to resolve external identifiers. |
Modifier and Type | Method and Description |
---|---|
static ResolverFeature<?> |
byName(java.lang.String name)
Find a known static feature by name.
|
T |
getDefaultValue()
Get the default value of the feature.
|
java.lang.String |
getName()
Get the name of the feature.
|
static java.util.Iterator<java.lang.String> |
getNames()
Iterates over all of the known feature names.
|
public static final ResolverFeature<java.util.List<java.lang.String>> CATALOG_FILES
public static final ResolverFeature<java.util.List<java.lang.String>> CATALOG_ADDITIONS
public static final ResolverFeature<java.lang.Boolean> PREFER_PUBLIC
public static final ResolverFeature<java.lang.Boolean> PREFER_PROPERTY_FILE
In earlier versions of this API, this was effectively always true.
The default is now false which allows system property values to override property file values.
Set this to true
in your property file to preserve the old behavior.
public static final ResolverFeature<java.lang.Boolean> ALLOW_CATALOG_PI
It defaults to true
, but there's a small performance cost. Each parse needs
it's own copy of the configuration if you enable this feature (otherwise, the PI in one document
might have an effect on other documents). If you know you aren't using the PI, it might be sensible
to make this false
.
public static final ResolverFeature<java.lang.String> CACHE_DIRECTORY
If the value
is null
, and CACHE_UNDER_HOME
is false
, no cache will
be used.
public static final ResolverFeature<java.lang.Boolean> CACHE_UNDER_HOME
.xmlresolver.org/cache
under the users home directory should be used for the cache.
This only applies if CATALOG_CACHE
is null
.
public static final ResolverFeature<ResourceCache> CACHE
ResourceCache
that the resolver is using.public static final ResolverFeature<CatalogManager> CATALOG_MANAGER
CatalogManager
that
the resolver is using.public static final ResolverFeature<java.lang.Boolean> URI_FOR_SYSTEM
uri
catalog entries
can be used to resolve external identifiers.
This only applies if resolution fails through system and public entries.
public static final ResolverFeature<java.lang.Boolean> MERGE_HTTPS
Historically, most web servers used http:
, now most use https:
.
There are existing catalogs that can't practically be updated that use http:
for
system identifiers and URIs. But authors copying and pasting are likely to get https:
URIs. If this option is true, then http:
and https:
are considred
the same for the purpose of comparison in the catalog.
This option has no effect on the URIs returned; it only influences catalog URI comparisons.
public static final ResolverFeature<java.lang.Boolean> MASK_JAR_URIS
When the resolver finds a resource, for example a schema or a stylesheet, it returns the location of the resolved resource as the base URI for the resource. This enables the following common scenario:
http://example.com/acme-schema/start/here
-> /opt/acme-schema-1.0/here
A document requests http://example.com/acme-schema/start/here
, the resolver
returns /opt/achme-schema-1.0/here
. When the schema attempts to import a library,
the URI for that library is resolved against the base URI on the filesystem, a new path is
constructed, and it all just works.
Adding support for classpath
and jar:
URIs to XML Resolver 3.0 has enabled another
very attractive scenario:
classpath:/org/example/acme-schema/catalog.xml
to your catalog list.Trouble is, the resolved URI will be something like this:
jar:file:///where/the/jar/is/acme-schema-1.0.jar!/org/example/acme-schema/here
And the trouble with that is, Java doesn't think the classpath:
and jar:
URI schemes are hierarchical and won't resolve the URI for the imported library correctly. It will
work just fine for any document that doesn't include parts with relative URIs. The DocBook schema,
for example, is distributed as a single RELAX NG file, so it works. But the xslTNG stylesheets would
not.
If MASK_JAR_URIS
is true, the resolver will return the local resource from the jar
file, but will leave the URI unchanged. As long as the catalog has a mapping for all of the resources,
and not just the entry point(s), this will do exactly the right thing.
Often, this can be achieved with, for example, a rewrite rule:
<rewriteURI uriStartString="http://example.com/acme-start/" rewritePrefix="acme-start/">
Assuming the catalog is in a location where that rewrite prefix works, the entry point will be remapped and the local resource returned. The resource it imports will be resolved against the http: URI, but that will also be remapped, and everyone wins.
You don't need to use a rewrite rule, you can use any combination of catalog rules you like as long as each of the requested URIs will be mapped.
public static final ResolverFeature<java.lang.String> CATALOG_LOADER_CLASS
The default catalog loader class is usually fine. The validating class can be used to enforce schema validity checks on loaded catalogs.
public static final ResolverFeature<java.lang.Boolean> PARSE_RDDL
If this feature is enabled, then if an attempt to get a namespace returns an HTML document, and if a nature and purpose has been specified in the request, the HTML document will be parsed for RDDL annotations. If a matching entry is found, the annotated URI will be used.
In the LSResourceResolver
, if the type of the request is the XML
Schema or RELAX NG namespace, the purpose is assumed to be validation.
public static final ResolverFeature<java.lang.Boolean> CLASSPATH_CATALOGS
If this feature is enabled, then the resolver will attempt to find and load all
of the catalogs named org/xmlresolver/catalog.xml
on the classpath.
These will be added to the of the catalogs loaded from properties.
public static final ResolverFeature<java.lang.ClassLoader> CLASSLOADER
A ClassLoader
is used to access the class path and load resources
from the class path. By default the resolver configuration uses the class
loader obtained from the class:
getClass().getClassLoader()
If you're using the resolver in an environment where an alternate class loader is required, you can specify it with this feature.
public static final ResolverFeature<java.lang.Boolean> ARCHIVED_CATALOGS
If enabled, then you can put ZIP files on the catalog path. The resolver
will look for catalog.xml
and org/xmlresolver/catalog.xml
,
using whichever it finds first. If it doesn't find either, the file is ignored.
public java.lang.String getName()
public T getDefaultValue()
public static ResolverFeature<?> byName(java.lang.String name)
name
- The feature name.public static java.util.Iterator<java.lang.String> getNames()