Are you sure the EntityResolver effects the reading of the external DTD? 
 I thought it only gets called for external entity declarations in the 
internal DTD, but the external DTD will still get loaded.  I could be 
wrong (especially since I just woke up).

Chris


Gary L Peskin wrote:

>Do you have a stack trace from the error that occurs when the DTD file
>cannot be found?  This might provide a clue.  I just really don't have
>the time at the moment to try to recreate this here and think about
>what's going wrong.  But a stack trace might provide a quick hint.
>
>Gary
>
>-----Original Message-----
>From: Yueming Xu [mailto:[EMAIL PROTECTED]] 
>Sent: Wednesday, October 17, 2001 12:47 PM
>To: [EMAIL PROTECTED]
>Subject: How to setEntityResolver when XMLFilter is used?
>
>
>In the following code, I tried to use my DummyEntityResolver, so it
>won't check for the existence of the DTD file for the incoming XML.
>However, it does not work.  It always tries to resolve the DTD file.
>What is wrong with this code?
>
>Thanks,
>Yueming
>
>// Setup reusable templates
>TransformerFactory tFactory =TransformerFactory.newInstance();
>Templates template1 = tFactory.newTemplates(new
>StreamSource(stylesheet1));
>Templates template2 = tFactory.newTemplates(new
>StreamSource(stylesheet2));
>
>// Set up to read the input file
>SAXParserFactory spf = SAXParserFactory.newInstance();
>spf.setNamespaceAware( true );
>spf.setValidating( false );
>SAXParser parser = spf.newSAXParser();
>XMLReader reader = parser.getXMLReader();
>reader.setEntityResolver(new DummyEntityResolver());
>
>// Set up the output stream
>StreamResult result = new StreamResult("result.txt");
>// Set up the input stream
>BufferedInputStream bis = 
>new BufferedInputStream(new FileInputStream(datafile));
>SAXTransformerFactory stf = (SAXTransformerFactory) tFactory;
>XMLFilter filter1 = stf.newXMLFilter(template1);
>XMLFilter filter2 = stf.newXMLFilter(template2);
>filter1.setParent(reader);
>filter2.setParent(filter1);
>
>Transformer transformer = stf.newTransformer();
>SAXSource transformSource = new SAXSource(filter2, new
>InputSource(bis));
>transformer.transform(transformSource, result);
>


Reply via email to