I have to process XML files that have a DTD with a XSLT in Java. The DTD is really needed because it contains the definitions of entities I use. (aside: yes, using entities for stuff that could use unicode is a bad idea ;-)
When I run the transformation it downloads the DTD from the external source every time. I want it to use a XML catalog to cache the DTDs so I gave the TransformerFactory
a CatalogResolver
as URIResolver
:
URIResolver cr = new CatalogResolver();
tf = TransformerFactory.newInstance();
tf.setURIResolver(cr);
Transformer t = tf.newTransformer(xsltSrc);
t.setURIResolver(cr);
Result res = new SAXResult(myDefaultHandler());
t.transform(xmlSrc, res);
But when I run the transformation it still downloads the DTDs over the network. (Using Xalan and Xerces either as part of Java5 or standalone or using Saxon and Xerces.)
What does it take to force the transformation to only use the local copy of the DTDs?