XPath 1.0查询JAXB对象? [英] XPath 1.0 queries on JAXB objects?

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

问题描述

JAXB非常棒,真正节省时间,但遍历生成的对象树仍然非常耗时;几乎与直接使用DOM一样糟糕。

JAXB has been great, a real timesaver, but it's still really time consuming to traverse the resulting object trees; almost as bad as working directly with the DOM.

有没有办法可以在JAXBElement上进行XPath 1.0查询,而不必每次都要在DOM模型上精心编组文档?

Is there a way that I can do XPath 1.0 queries on a JAXBElement, without having to painstakingly marshal the document to and from a DOM model each time?

推荐答案

不直接,没有。但是,您可以使用 Apache Commons Jxpath ,它允许您跨任意对象图运行XPath查询,而不是只是JAXB绑定的。它可以在宽松模式下运行,该模式可以容忍空值。

Not directly, no. However, you can use Apache Commons Jxpath, which allows you to run XPath queries across arbitrary object graphs, not just JAXB-bound ones. It can be run in "lenient" mode, which is tolerant of nulls.

非常便于替换那些易于发生NPE的图导航。

Extremely handy for replacing those NPE-prone graph navigations.

这篇关于XPath 1.0查询JAXB对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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