Even without validation on a SAX parser will typically try to resolve any DOCTYPE it finds.
So you could just make up your own DTD for the document. Any document with a DOCTYPE should have a DTD file in existence somewhere around in this universe - so just make a copy of it locally and put it on your classpath or whatever and use the EntityResolver. Another approach is you might be able to configure the underlying SAX parser to not look at the DOCTYPE. e.g. if you're using Xerces 2.0 you could try one of these features, try turning them off and seeing if it works... http://xml.apache.org/xerces2-j/features.html e.g. try turning off this feature http://apache.org/xml/features/nonvalidating/load-external-dtd String feature = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; SAXReader reader = new SAXReader(); reader.setFeature( feature, false ); Document doc = reader.read( "foo.xml" ); BTW I've added the EntityResolver question to the FAQ in CVS; it'll just take a little while to make it into the website as we've got build problems right now. James ----- Original Message ----- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, May 17, 2002 12:47 PM Subject: Re: [dom4j-user] disable DTD validation ? Hi James and Sri, thanks for your responses. I still have the problem because - I can not use James' solution because I do not have a DTD at all. (The sample is great, why is it not in the dom4j FAQ ???) - I can not use Sri's solution because although validation is not done, dom4j will still try to retrieve the DOCTYPE DTD. Is there a way to completly switch of validation _and_ DTD retrieval ? regards Mike --- On Fri 05/17, James Strachan wrote: Please see the mail I sent yesterday; the trick is to provide your own SAX EntityResolver to the SAXReader so that the underlying SAX parser can load the DTD from whereever you wish; like from the JAR or classpath from where your code came. http://www.mail-archive.com/dom4j-user%40lists.sourceforge.net/msg00829.html James Hi there, I am just experimenting with the dom4j parser and I am wondering, if there is an easy way to diable the DTD validation ? My problem is, that my document contains a DOCTYPE with a non existing DTD, which dom4j tries to retrieve... thanx Mike Join Excite! - http://www.excite.com The most personalized portal on the Web! _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user