Jython和SAX Parser:不允许超过64000个实体?

时间:2011-02-23 22:09:22

标签: python xml jython sax saxparser

我在一个大型XML文件(800 MB)上对Jython中的xml.sax解析器进行了简单测试,遇到以下错误:

Traceback (most recent call last):
  File "src/project/xmltools.py", line 92, in <module>
    sys.exit(main())
  File "src/project/xmltools.py", line 87, in main
    parser.parse(open(argv[1], "r"))
  File "/amd.home/home/user/workspace/jython-2.5.2/Lib/xml/sax/drivers2/drv_javasax.py", line 146, in parse
    self._parser.parse(JyInputSourceWrapper(source))
  File "/amd.home/home/user/workspace/jython-2.5.2/Lib/xml/sax/drivers2/drv_javasax.py", line 59, in fatalError
    self._err_handler.fatalError(_wrap_sax_exception(exc))
  File "/amd.home/home/user/workspace/jython-2.5.2/Lib/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:1: The parser has encountered more than "64,000" entity expansions in this document; this is the limit imposed by the application.

这个“应用程序强加的限制”有什么问题?如何覆盖它?

我尝试使用Java XML库nu.xom并遇到了同样的错误。

1 个答案:

答案 0 :(得分:5)

尝试将entityExpansionLimit属性设置为高于64000的值。请参阅http://download.oracle.com/javase/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html#JAXP_security