Jasper Reports 使用 Xpath 函数
Jasper Reports use Xpath functions
我们正在使用 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}).subDataSource("distinct-values(/connections/message/type)")
有谁知道如何在 Jasper Reports, jrxml 文件中使用 XPath 函数?
distinct-values()
是 XPath 2.0 独有的函数。不幸的是,Jasper Reports only support XPath 1.0(具有讽刺意味的是,论坛 post 与此完全相同)。
简短的回答是:不,没有从一组节点中消除重复值的 XPath 1.0 函数。
如果您可以显示更多输入 XML 文档,可能有解决此问题的方法。
编辑:作为记录,这是 OP 从 Jasper Reports 论坛获得的答案:
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
我不同意 "a few things not to like" 关于 XPath 2.0 的说法,但至少这是一个明确的答案。
我们正在使用 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}).subDataSource("distinct-values(/connections/message/type)")
有谁知道如何在 Jasper Reports, jrxml 文件中使用 XPath 函数?
distinct-values()
是 XPath 2.0 独有的函数。不幸的是,Jasper Reports only support XPath 1.0(具有讽刺意味的是,论坛 post 与此完全相同)。
简短的回答是:不,没有从一组节点中消除重复值的 XPath 1.0 函数。
如果您可以显示更多输入 XML 文档,可能有解决此问题的方法。
编辑:作为记录,这是 OP 从 Jasper Reports 论坛获得的答案:
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
我不同意 "a few things not to like" 关于 XPath 2.0 的说法,但至少这是一个明确的答案。