Chapter 4Using an XML Resolver

The simplest possible thing you can do is instantiate an instance of org.xmlresolver.XMLResolver and use it to obtain a resolver for each of the XML parsing APIs that you are using.

Call this method:To obtain:
getEntityResolver()A SAX1 org.xml.sax.EntityResolver
getEntityResolver2()A SAX2 org.xml.sax.ext.EntityResolver2
getURIResolver()A JAXP javax.xml.transform.URIResolver
getLSResourceResolver()A W3C DOM org.w3c.dom.ls.LSResourceResolver
getXMLResolver()A StAX javax.xml.stream.XMLResolver

Another simple integration point is to instantiate org.xmlresolver.tools.ResolvingXMLReader as your XML parser.

1Programming 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 an XML Resolver:

  |XMLResolver resolver = new XMLResolver(config);

and use that resolver in your parsing and URI retrieval.

  |myXmlReader.setEntityResolver(resolver.getEntityResolver2());

For additional APIs, consult the JavaDoc.