如何让JDOM忽略DTD声明
一个XML文档(mapping.xml),有DTD声明如下:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
我要用JDOM解析这个文档,代码如下:
InputStream in = getClass().getClassLoader().getResourceAsStream("mapping.xml");
Document document = new SAXBuilder().build(in);
在执行第二句的时候抛出异常:
java.net.UnknownHostException: castor.exolab.org
将DTD声明删除即可正常解析。请问如何让JDOM直接忽略DTD声明完成解析?