Schema Resolving

XSD Schema resolving is done through the SchemaResolver class.


This supports resolution of schemas obtained from an OASIS Catalog, the Java classpath, or cached network download, or all three.

This class will resolve any resource type, but it is designed to aid relative imports between XML Schemas; to do this it keeps a reverse-lookup table to convert resolved locations back to their original locations, facilitating correct determination of relative imports and includes. To ensure that this works, use a single instance of SchemaResolver to resolve a schema and all its dependencies.

Optional SchemaResolver constructors arguments allow configuration of permitted resolution methods.

OASIS Catalog

The resolver can be configured to use an OASIS Catalog to resolve schema locations. The resolver uses catalog URI semantics to locate schemas, so uri or rewriteURI entries should be present in your catalog.


SchemaResolver resolver = new SchemaResolver( File("/path/to/catalog.xml"))));


Schema resolution on the classpath is always enabled. For example, a schema resolves to /org/example/schemas/exampleml/exml.xsd on the classpath. To create a resolver with only support for schemas on the classpath, use the default constructor:

SchemaResolver resolver = new SchemaResolver();


If the resolver is configured to use a cache, schemas not resolved by other methods will be downloaded from the network and stored in the cache directory. For example, a schema published at would be downloaded and stored as org/example/schemas/exampleml/exml.xsd in the cache directory.


SchemaResolver resolver = new SchemaResolver(new SchemaCache(new File("/path/to/schema-cache"), true));

If downloads are not enabled, a pre-populated cache will still be used, but missing schemas will not be downloaded.