You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Rick Stevens <ri...@us.ibm.com> on 2001/02/05 16:08:10 UTC

Preventing the loading of DTDs during transformation

Hi,
I'm using the Xalan-J version 1 and am having a problem where the XSLT
processor wants to load all of the DTD files referenced by the document.
The real problem is that there are so many individual elements (about 15)
that it can take up to a minute to retrieve them all and finish the
transformation.  I believe the time is spent on the retrieval over the
network of the files.

I had hoped that I could use a documented Xerces feature to prevent even
loading the DTD.  I could then create a DOMParser, which specifies that
feature-- "http://apache.org/xml/features/nonvalidating/load-dtd"-- which,
in theory, should prevent the loading of the DTD, but I get a "SAX not
recognized" exception when I use it.

The code is as follows:

     // xmlIn is a InputStream
     // ssr is a compiled stylesheet
     // baos is a ByteArrayOutputStream

     // parse the document into a DOM tree
     DOMParser parser = new DOMParser();
     parser.setFeature( "http://apache.org/xml/features/nonvalidating/load-dtd", false);
     parser.parse( new InputSource(xmlIn) );
     Document doc = parser.getDocument();

     // transform the DOM tree into the result
     xslProcessor.setStylesheet( ssr );
     xslProcessor.setProblemListener(probListener);
     xslProcessor.process(    new XSLTInputSource( doc ),
                                   null,
                                   new XSLTResultTarget( baos ) );


Does anyone know how to prevent the loading of the DTD?   Is this supported in Xalan-Java 2?

Thanks,
Rick Stevens
AT & T