<div id="RTEContent"><b><i>Andrew Zahra <andrew.zahra@gmail.com></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> I am trying to parse a simple document being sent to me over TCP. I am using the SAXBuilder class with its default constructor. Problem is the XML doc I am receiving specifies a DTD. Even though I am not validating the document I get an error saying that the external DTD file is not found.<br> <br> <br> If I create an empty DTD file it is happy, but I don't want to do this.<br> <br> Is there any way I can stop it trying to open the external DTD or supress the error and make it continue?<br> <br> I did try using setErrorHandler with an error handler that just returned on error but that didn't work.<br></blockquote>The reason SAX parser tries to read the DTD nonetheless is since it might contain parsed entities that may be referenced by the document. Some parsers do this lazily, ie. only
if they encounter an unknown entity.<br> There are ways around this problem, the simplest is probably to just create a dummy EntityResolver that just resolves any references to the external DTD to return empty content (or anything that's valid DTD; this should be easy): this should resolve your problem.<br> <br> Another possibility would be using parsers where DTD support can be disabled; StAX parsers for example have a property to use that completely disables handling of DTDs. ;-)<br> (I wrote StAXBuilder that can be used to build JDom documents using a StAX XMLStreamReader).<br> <br> -+ Tatu +-<br> <br> <br></div><p>
                <hr size=1> <B>Yahoo! Personals</B><BR>
Single? There's someone we'd like you to meet.<BR>
Lot's of someone's, actually. <a href="http://us.rd.yahoo.com/evt=36108/*http://personals.yahoo.com
">Yahoo! Personals</a>