Java-XML数据绑定工具大比拼

把Java对象映射成XML文档,这是Java对象持久化的一种新思路。在XML.com的一篇文章里,作者对四种主要的Java-XML映射工具进行了全面的比较:

比较的标准主要有以下几条:(1)对XML大纲(schema)特性的支持程度;(2)生成Java代码的可用性;(3)Java-XML转换(以及反向转换)的工作情况。

测试的结果如下。可以看到,Sun的JAXB参考实现竟然有着绝佳的表现,不论在性能还是特性集方面,都仅次于XGen,名列第二。这让我对JAXB又多了几分信心。

Over-all test results for all four tools.

Test results broken down by test case category.

Feature

Breeze

Castor

JAXB RI

XGen

Customization Disallowed

no

no

no

yes

Package Name Mapped from Namespace

no

no

yes1

yes

Automatic Unmarshaling

no

no

no

yes

Open Source

no

yes

no2

yes

Free of Charge

no

yes

yes

yes

Schema Location Roundtrippable

no

no

no

yes

Schema Location Settable

no

yes3

yes3

yes

Schemas without a Target Namespace Supported

yes

yes

yes

no

Instance Validation on Unmarshal

no

yes

yes4

yes

Constraint Check of Values on Set

5

no

no

yes

Value Validation when Marshaling

no

yes

no

5

Code Generation Command Line Tool Interface

yes

yes

yes

yes

Code Generation Programmatic Interface

no

yes

no

yes

Code Generation GUI Interface

yes

no

no

no

Generated Code Implements Generic Interfaces

yes

no

yes6

yes

1 -- Mapped if no other package name is specified.
2-- JAXB will be available as an open source project in the upcoming future. More information can be found at http://jaxb.dev.java.net/.
3 -- Only on marshaller class.
4 -- Off by default.
5 -- Some values validated.
6 -- Interfaces based on functionality instead of type of XML Schema construct.



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2419


你可能感兴趣的:(java)