Stax解析中对DTD的处理

xml文件的开始部分如下:

<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE NMSI_PM SYSTEM "NPI_PM.DTD">

我在用stax解析该文件时,会报错找不到NPI_PM.DTD文件。

 

想请假一下,如何让stax解析不会对doctype部分进行处理呢?

 

因为对于我要处理的xml文件来说,doctype部分是多余的(但是存在的)。

   documentBuilder.setEntityResolver(new EntityResolver()
    {
        public InputSource resolveEntity(String publicId, String systemId)
            throws SAXException, IOException
        {
            return new InputSource(new StringReader(""));
        }
    });

返回一个空的 以忽略