你推荐什么Java XML库(替换dom4j)? [英] What Java XML library do you recommend (to replace dom4j)?

查看:173
本文介绍了你推荐什么Java XML库(替换dom4j)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找像dom4j这样的东西,但是没有dom4j的瑕疵,例如文档不好或丢失,看似停滞的开发状态。

I'm looking for something like dom4j, but without dom4j's warts, such as bad or missing documentation and seemingly stalled development status.

背景:我去过使用 发送 dom4j,但感觉不完全正确因为我知道这个库远非最优(例如:看看XSLT中的方法如何相关样式表类已记录;您将以字符串模式参数传递给run()的内容是什么?)

Background: I've been using and advocating dom4j, but don't feel completely right about it because I know the library is far from optimal (example: see how methods in XSLT related Stylesheet class are documented; what would you pass to run() as the String mode parameter?)

要求:
库中的基本XML处理比使用 纯JDK javax.xml org.w3c.dom 包)。这样的事情:

Requirements: The library should make basic XML handling easier than it is when using pure JDK (javax.xml and org.w3c.dom packages). Things like this:


  • 将XML文档(从文件或字符串)读入对象,轻松遍历和操作DOM,执行XPath查询并针对它运行XSLT。

  • 在Java代码中构建XML文档,添加元素和属性以及数据,最后将文档写入文件或字符串。

我真的很喜欢 dom4j承诺,实际上:易于使用的开源库,用于处理XML,XPath和XSLT [...],完全支持DOM,SAX和JAXP。即将推出的dom4j 2.0确实声称可以解决所有问题:充分利用Java 5并添加缺少的文档。但不幸的是,如果您仔细观察

I really like what dom4j promises, actually: "easy to use, open source library for working with XML, XPath and XSLT [...] with full support for DOM, SAX and JAXP." And upcoming dom4j 2.0 does claim to fix everything: fully utilise Java 5 and add missing documentation. But unfortunately, if you look closer:


警告:dom4j 2.0处于pre-alpha
阶段。它很可能不是
编译的。如果可以随机编译
,很可能无法运行。
如果它偶尔运行,它可以突然爆炸
。如果你想使用
dom4j,你需要版本1.6.1。真的。

Warning: dom4j 2.0 is in pre-alpha stage. It is likely it can't be compiled. In case it can be compiled at random it is likely it can't run. In case it runs occasionally it can explode suddenly. If you want to use dom4j, you want version 1.6.1. Really.

......网站已经说了很长时间。那么有没有一个很好的替代dom4j?请为您的首选库提供一些理由,而不仅仅是转储名称和链接。 : - )

...and the website has said that for a long time. So is there a good alternative to dom4j? Please provide some justification for your preferred library, instead of just dumping names and links. :-)

推荐答案

当然, XOM : - )


XOM旨在轻松学习
且易于使用。它直接工作非常b $ b,并且有一个非常b $ b b的学习曲线。假设
你已经熟悉XML了,那么
应该能够非常快速地启动并运行

XOM is designed to be easy to learn and easy to use. It works very straight-forwardly, and has a very shallow learning curve. Assuming you're already familiar with XML, you should be able to get up and running with XOM very quickly.

我现在使用XOM好几年了,我仍然非常喜欢它。易于使用,Web上有大量文档和文章,API在版本之间不会发生变化。 1.2最近发布。

I use XOM for several years now, and I still like it very much. Easy to use, plenty of documentation and articles on the web, API doesn't change between releases. 1.2 was released recently.


XOM是唯一一个没有
妥协正确性的XML API。 XOM只接受
命名空间格式良好的XML
文档,并且只允许
创建名称空间格式良好的XML
文档。 (事实上​​,它比这更严格
:实际上
保证所有文件都是
可循环使用并且具有明确定义的
XML信息集。)XOM管理你的XML所以
你没必要。使用XOM,您可以将
专注于
应用程序的唯一值,并信任XOM以获得
XML。

XOM is the only XML API that makes no compromises on correctness. XOM only accepts namespace well-formed XML documents, and only allows you to create namespace well-formed XML documents. (In fact, it's a little stricter than that: it actually guarantees that all documents are round-trippable and have well-defined XML infosets.) XOM manages your XML so you don't have to. With XOM, you can focus on the unique value of your application, and trust XOM to get the XML right.

查看网页 http://www.xom.nu/ 以获取常见问题解答,食谱,设计原理等。如果只有一切都是如此多的爱设计: - )

Check out web page http://www.xom.nu/ for FAQ, Cookbook, design rationale, etc. If only everything was designed with so much love :-)

作者也写了关于 XML API的错误(以及如何修复它们)。 (基本上,XOM首先存在的原因)

Author also wrote about What's Wrong with XML APIs (and how to fix them). (Basically, reasons why XOM exists in the first place)

这里还有5部分的Artima访谈作者关于XOM,他们在那里谈论 XML API有什么问题好,坏,和DOM A JDOM的设计评审从JDOM学到的经验教训,最后设计原则和XOM

Here is also 5-part Artima interview with author about XOM, where they talk about what's wrong with XML APIs, The Good, the Bad, and the DOM, A Design Review of JDOM, Lessons Learned from JDOM and finally Design Principles and XOM.

这篇关于你推荐什么Java XML库(替换dom4j)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆