XPath 1.0 queries on JAXB objects?(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 模型和从 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 对象的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:XPath 1.0 对 JAXB 对象的查询?


基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01