【问题标题】:How to ignore DTD parsing in Apache's AXIOM如何在 Apache 的 AXIOM 中忽略 DTD 解析
【发布时间】: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 解析器来处理这个问题。

标签: xml axiom


【解决方案1】:

这将在 Axiom 1.2.16 中修复(参见 AXIOM-475)。同时,您可以使用 Woodstox(4.0 或更高版本)作为 StAX 实现来解决此问题。

【讨论】:

  • 您好 Andreas,看来您已经解决了这个问题。请提供示例代码。
猜你喜欢
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-15
  • 2012-07-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多