I read the Xerces-J website help on setting up the XMLCatalogResolver but can't seem to get it working. I need to use it when parsing HTML with the standard DTD declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> w3.org have recently blocked access to all DTDs on their site, so if I can't get this working then I can't use Xerces to parse HTML! Here is my test code: <code> XMLCatalogResolver resolver = new XMLCatalogResolver(); resolver.setCatalogList(new String[] {"c:\\data\\4.0-patch\\Java\\Server\\lib_doNotDistribute\\thcatalog.cat"}); parser.getXMLReader().setProperty("http://apache.org/xml/properties/internal/entity-resolver", resolver); parser.getXMLReader().setContentHandler(new TestResolver()); parser.getXMLReader().parse(new InputSource(fis)); </code> I've done a little debugging in the xerces code and the resolver gives up because the namespace is null, see the following snippet from the code of XMLCatalogResolver: <code> // The namespace is useful for resolving namespace aware // grammars such as XML schema. Let it take precedence over // the external identifier if one exists. String namespace = resourceIdentifier.getNamespace(); if (namespace != null) { resolvedId = resolveURI(namespace); } </code> I'm guessing that the namespace is something that really only applies to XSD references and not DTDs or did I misunderstand. Does anyone else have this working? My catalog file matches the many examples available on the web but I include here for completeness: <?xml version="1.0"?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <public publicId="-//W3C//DTD XHTML 1.0 Strict//EN" uri="dtd/xhtml1-transitional.dtd"/> </catalog> Thanks, Chris -- View this message in context: http://www.nabble.com/Resolving-DTD-system-URI-with-XMLCatalogResolver-tp23988310p23988310.html Sent from the Xerces - J - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org