Parsing XML with invalid URI for DTD

When parsing an XML file (with aelfred2) I get the following error:

Exception in thread "main" gnu.xml.dom.ls.DomLSException: Absolute URL required with null context: CQCGWProtocol.DTD

at gnu.xml.dom.ls.DomLSParser.doParse(libgcj.so.7)

at gnu.xml.dom.ls.DomLSParser.parse(libgcj.so.7)

at gnu.xml.dom.DomDocumentBuilder.parse(libgcj.so.7)

at CQC.main(CQC.java:44)

Caused by: java.net.MalformedURLException: Absolute URL required with null context: CQCGWProtocol.DTD

at java.net.URL.<init>(libgcj.so.7)

at java.net.URL.<init>(libgcj.so.7)

at gnu.xml.aelfred2.XmlParser.pushURL(libgcj.so.7)

at gnu.xml.aelfred2.XmlParser.parseDoctypedecl(libgcj.so.7)

at gnu.xml.aelfred2.XmlParser.parseProlog(libgcj.so.7)

at gnu.xml.aelfred2.XmlParser.parseDocument(libgcj.so.7)

...

I'm puzzled, as I have disabled validation:

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

domFactory.setIgnoringComments(true);

domFactory.setNamespaceAware(false);

domFactory.setValidating(false);

My goal is to have the parser ignore the DOCTYPE tag and not try to find the DTD. Can someone suggest how you turn this off - apparently, setting the validation to false is not the right approach.

I'm running Java 1.4.2 on Fidora Core 5.

Thanks for suggestions!

[1399 byte] By [siegelda] at [2007-11-26 19:56:23]
# 1

Create an org.xml.sax.EntityResolver and apply it to your parser. The API documentation for the interface has an example of how to write one.

And no, turning of validation doesn't turn off processing of DTDs because DTDs are for things other than validation. Entity replacement, for example.

DrClapa at 2007-7-9 22:50:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...