Java - XML 解析器性能:Sun Java Streaming XML Parser (SJSXP) vs Woodstox

2022-01-10 00:00:00 xml xml-parsing java stax woodstox

我正在寻找最新的、内存效率高的高性能 java XML 解析 API.我需要解析 3 MB 到 5 MB 的 XML 文件.

I am looking for latest, memory efficient and high-performance java XML parsing API. I need to parse 3 MB to 5 MB XML files.

我对此进行了谷歌搜索,了解到 Sun Java Streaming XML Parser (SJSXP) 和 Woodstox 比 DOM 快得多.萨克斯.两者都使用 StAX API.*这些技术不支持模式验证.

I did google on this and come to know about Sun Java Streaming XML Parser (SJSXP) and Woodstox is much faster than DOM & SAX. Both are using StAX API. *schema validation is not supported by these technologies.

Aalto XML 处理器也实现了 StAX API.

Aalto XML processor is also implements StAX API.

我还没有找到关于这些技术性能的具体发现.

I have not found concrete findings on performance on these technologies.

在内存效率、高性能和易用性方面哪一个是最好的?

Which one will be best in context of memory efficient, high-performance and ease of use ?

推荐答案

这里还有一些可能相关的链接:

Here are some more links that might be relevant:

  • 用于数据绑定的 Stax 实现:http://technotes.blogs.sapo.pt/1708.html
  • 高效使用 Woodstox:http://www.cowtowncoder.com/blog/archives/2006/06/entry_2.html
  • 使用 Woodstox 加速 XSLT:http://www.cowtowncoder.com/blog/archives/2009/04/entry_235.html

性能方面:SJSXP 最慢;它只是 Xerces 内部的重新包装,包装在 Stax API 中.这对性能有一些负面影响(因为它并不是真正为拉解析而设计的).伍德斯托克斯快一点;小文档和写作速度更快,解析较长文档时差异更小.

As to performance: SJSXP is the slowest; it's just a repackage internals of Xerces, wrapped in Stax API. This has some negative effects on performance (since it's not really designed for pull parsing). Woodstox is bit faster; much faster for small documents and writing, less difference when parsing longer documents.

到目前为止,Aalto 是三者中最快的,尤其是在解析方面.它通常比 Woodstox 或 SJSXP 快 50% - 100%.一个缺点是它不处理 DTD(因此不处理外部实体;它处理预定义和字符实体).

And Aalto is by far fastest of the three, especially for parsing. It is commonly 50% - 100% faster than either Woodstox or SJSXP. One downside is that it does not handle DTDs (and thereby not external entities; it handles pre-defined and character entities).

免责声明:我是 Woodstox 和 Aalto 的作者;以及 SJSXP 的贡献者(错误修复)

Disclaimer: I am author of Woodstox and Aalto; as well as contributor to SJSXP (bug fixes)

相关文章