Jython 和 SAX 解析器:允许的实体不超过 64000 个?

发布于 2024-10-18 14:46:41 字数 1046 浏览 2 评论 0原文

我在 Jython 中对大型 XML 文件 (800 MB) 中的 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 并遇到了相同的错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜访吸血鬼 2024-10-25 14:46:41

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文