Jython and the SAX Parser: No more than 64000 entities allowed?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 10:48:42

问题


I've done a simple test of the xml.sax parser in Jython on a large XML file (800 MB) and encountered the following error:

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.

What is the matter with this "limit imposed by the application" and how can I override it?

I have tried to use the Java XML library nu.xom and ran into the same error.


回答1:


Try setting the entityExpansionLimit property to a higher value than 64000. See http://download.oracle.com/javase/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html#JAXP_security.



来源:https://stackoverflow.com/questions/5097823/jython-and-the-sax-parser-no-more-than-64000-entities-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!