gpt4 book ai didi

xpath - Jasper Reports 使用 Xpath 函数

转载 作者:行者123 更新时间:2023-12-03 05:29:26 26 4
gpt4 key购买 nike

我们正在使用 Jasper Report 的 xml 数据源。要创建一些输出,我们需要 XPath distinct-values() 函数 as described 。如果我按照描述的方式使用它,Jasper Studio 会给我一个错误:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDa‌​taSource("distinct-values(/connections/message/type)")

有人知道如何在 Jasper Reports、jrxml 文件中使用 XPath 函数吗?

最佳答案

distinct-values() 是 XPath 2.0 独有的函数。不幸的是,Jasper Reports only support XPath 1.0 (讽刺的是,论坛帖子的内容完全相同)。

简短的回答是:不,没有 XPath 1.0 函数可以消除一组节点中的重复值。

如果您可以显示更多输入 XML 文档,则可能有办法解决此问题。

<小时/>

编辑:作为记录,以下是 OP 从 Jasper 报告论坛获得的答案:

Hi, I talked with JR Team in order to better clarify the topic. So currently the version supported is XPath version 1.0. This because JR relies on Xalan or Jaxen for XPath support. These thirdy-part libraries currently support version 1.0.

Looking at the Jaxen FAQ it seems to be a "strict" decision they made, focusing only on compatibility support: http://jaxen.codehaus.org/faq.html

Which version of XPath does jaxen support? Does jaxen support XPath 2?

jaxen supports XPath 1.0. It does not support XPath 2.0. XPath 2.0 is a very different spec with many things to recommend it and a few things not to like as well. However XPath 2.0 is not compatible with XPath 1.0. It is far from a simple upgrade from XPath 1.0. It has a very different data model, that might well require significant revisions to jaxen's internal data structures, and possibly a very different API as well.

The current release plan focuses exclusively on XPath 1.0 compatibility. Perhaps one day someone will make a branch or fork of jaxen that supports XPath 2. However, this would be a significant undertaking, and so far little interest in this has been shown.

Therefore for the moment we will stay with version 1.0 of XPath

我不同意关于 XPath 2.0 的“一些不喜欢的事情”,但至少这是一个明确的答案。

关于xpath - Jasper Reports 使用 Xpath 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29076260/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com