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.EntityResolverthe SAX1 interface used to load XML entitiesorg.xml.sax.ext.EntityResolver2the SAX2 interface used to load XML entitiesjavax.xml.transform.URIResolverused to load XSLT resourcesorg.w3c.dom.ls.LSResourceResolverused by the DOM to load resourcesorg.xmlresolver.NamespaceResolveran interface for loading namespace-based resources based on RDDL that never really took off, but there you go.javax.xml.stream.XMLResolverthe StAX interface used to load XML entities. (This interface is actually supported by theorg.xmlresolver.StAXResolverclass because the StAXXMLResolverAPI and the SAXEntityResolver2APIs 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.