DTD无法访问,导致解析XML出错。
在xml 文档中有如下的 DTD申明:
<!DOCTYPE othrsdata SYSTEM "OTHRS02.DTD" >
因为某些原因,XML文件无法被修改。
使用apache的xerces解析时,因为要用XSD文件验证XML,所以设定了
builder.setFeature("http://xml.org/sax/features/validation",true);
builder.setFeature("http://apache.org/xml/features/validation/schema",true);
这时候
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
就显得没有意义了,每次都会去装载DTD文件。
如何让它跳过DTD验证,xsd验证又能正确执行?