Chapter 4. Using an XML Resolver
The simplest possible thing you can do is instantiate an instance of
org.xmlresolver.Resolver
and use it as the resolver for your parser.
The Resolver
class implements the following resolvers:
org.xml.sax.EntityResolver
the SAX1 interface used to load XML entitiesorg.xml.sax.ext.EntityResolver2
the SAX2 interface used to load XML entitiesjavax.xml.transform.URIResolver
used to load XSLT resourcesorg.w3c.dom.ls.LSResourceResolver
used by the DOM to load resourcesorg.xmlresolver.NamespaceResolver
an interface for loading namespace-based resources based on RDDL that never really took off, but there you go.javax.xml.stream.XMLResolver
the StAX interface used to load XML entities. (This interface is actually supported by theorg.xmlresolver.StAXResolver
class because the StAXXMLResolver
API and the SAXEntityResolver2
APIs are incompatible.)
Another simple integration point is to instantiate
org.xmlresolver.tools.ResolvingXMLReader
as your XML parser.
1. Programming with the resolver
If you want to take more complete programmatic control of the resolver, instantiate a resolver configuration:
|XMLResolverConfiguration config
|= new XMLResolverConfiguration(propertyFiles, catalogs);
Set the features as you wish:
1 |config.setFeature(ResolverFeature.DEFAULT_LOGGER_LOG_LEVEL, "info");
||
if (validateCatalogs) {
|config.setFeature(ResolverFeature.CATALOG_LOADER_CLASS,
5 |"org.xmlresolver.loaders.ValidatingXmlLoader");
|}
Then instantiate a resolver:
|Resolver resolver = new Resolver(config);
and use that resolver in your parsing and URI retrieval.
For additional APIs, consult the JavaDoc.