【发布时间】:2016-02-04 11:11:28
【问题描述】:
在我的 xml 文档中,存在 doctype。在使用 Apache Axiom 解析 xml 文档时,它会抛出以下错误消息“org.apache.axiom.om.OMException: Cannot create OMDocType because the XMLStreamReader does not support the DTDReader extension”。
XMLStreamReader parser = null;
try {
StAXParserConfiguration standalone = StAXParserConfiguration.STANDALONE;
parser= StAXUtils.createXMLStreamReader(standalone, in);
// parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
}
catch (XMLStreamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (FactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StAXOMBuilder builder=new StAXOMBuilder(parser);
OMElement rootOMElement = builder.getDocumentElement();
【问题讨论】:
-
从文档中删除文档类型将解决此问题。但我希望 Axiom 解析器来处理这个问题。