CatalogResolver extends AbstractResolver { public synchronized void resolve(Identifier id, Input input) throws IOException, ResolverException { if (input.isResolved()) return; if (hadCatalogError) return; String absoluteUri = null; try { absoluteUri = BasicResolver.resolveUri(id); if (id.getUriReference().equals(absoluteUri)) absoluteUri = null; } catch (ResolverException e) { } String resolved = null; boolean isExternalIdentifier = (id instanceof ExternalIdentifier); try { if (!catalogLoaded) { catalogLoaded = true; catalog.loadSystemCatalogs(); } if (absoluteUri != null) resolved = isExternalIdentifier ? catalog.resolveSystem(absoluteUri) : catalog.resolveURI(absoluteUri); if (resolved == null) { if (!isExternalIdentifier) resolved = catalog.resolveURI(id.getUriReference()); else if (id instanceof ExternalEntityIdentifier) { ExternalEntityIdentifier xid = (ExternalEntityIdentifier)id; resolved = catalog.resolveEntity(xid.getEntityName(), xid.getPublicId(), xid.getUriReference()); } else if (id instanceof ExternalDTDSubsetIdentifier) { ExternalDTDSubsetIdentifier xid = (ExternalDTDSubsetIdentifier)id; resolved = catalog.resolveDoctype(xid.getDoctypeName(), xid.getPublicId(), xid.getUriReference()); } else { ExternalIdentifier xid = (ExternalIdentifier)id; resolved = catalog.resolvePublic(xid.getPublicId(), xid.getUriReference()); } } } catch (ResolverIOException e) { hadCatalogError = true; throw e.getResolverException(); } if (resolved != null) input.setUri(resolved); } CatalogResolver(Catalog catalog);  CatalogResolver(List<String> catalogUris, SAXResolver resolver);  CatalogResolver(List<String> catalogUris, Resolver resolver);  CatalogResolver(List<String> catalogUris); synchronized void resolve(Identifier id, Input input);  }
@Test public void testResolve() throws IOException, ResolverException { List<String> catalogs = new ArrayList<String>(); catalogs.add(resourceUri("catalog.xml")); Resolver resolver = new CatalogResolver(catalogs, new SAXResolver(null)); ExternalIdentifier xid = new ExternalIdentifier("foo.xml", "http: Input input = new Input(); resolver.resolve(xid, input); Assert.assertEquals(input.getUri(), "http: }