Xerces has an XML Catalog implementation in the class:
org.apache.xerces.util.XMLCatalogResolver
You just create the class and set the list of catalog files:
String catalogURI = "file:"+(new File(catalogFile)).getAbsolutePath(); String [] catalogs = { catalogURI }; // Create catalog resolver and set a catalog list. XMLCatalogResolver resolver = new XMLCatalogResolver(); resolver.setPreferPublic(true); resolver.setCatalogList(catalogs);
Then set the appropriate property:
// Set the resolver on the parser. xmlReader.setProperty( "http://apache.org/xml/properties/internal/entity-resolver", resolver );