Java XML绑定 [英] Java XML Binding

查看:137
本文介绍了Java XML绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您使用什么将XML绑定到Java? JAXB,Castor和XMLBeans是一些可用的选择。我见过的比较都是三四年。我愿意接受其他建议。编组/解组表现和易用性特别令人感兴趣。

What are you using for binding XML to Java? JAXB, Castor, and XMLBeans are some of the available choices. The comparisons that I've seen are all three or four years old. I'm open to other suggestions. Marshalling / unmarshalling performance and ease of use are of particular interest.

澄清:我不仅想看你使用的是什么框架,还想看看你使用的是什么框架其他人。

Clarification: I'd like to see not just what framework you use, but your reasoning for using one over the others.

推荐答案

JiBX 。以前我使用 Castor XML ,但JiBX被证明要明显更好,特别是在性能方面(从Castor XML到JiBX的一些应用程序代码的直接端口使其快9倍)。我还发现JiBX的映射格式比Castor更优雅。

JiBX. Previously I used Castor XML, but JiBX proved to be significantly better, particularly in terms of performance (a straight port of some application code from Castor XML to JiBX made it 9x faster). I also found the mapping format for JiBX to be more elegant than Castor's.

JiBX通过使用后编译字节码操作而不是Castor采用的反射方法来实现其性能。这样做的好处是它对编写映射类的方式提出的要求更少。不需要getter,setter和no-arg构造函数来满足这些工具。大多数情况下,您可以在不考虑映射问题的情况下编写类,然后在不进行修改的情况下对其进行映射。

JiBX achieves its performance by using post-compilation bytecode manipulation rather than the reflection approach adopted by Castor. This has the advantage that it places fewer demands on the way that you write your mapped classes. There is no need for getters, setters and no-arg constructors just to satisfy the tools. Most of the time you can write the class without considering mapping issues and then map it without modifications.

这篇关于Java XML绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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