开发者

JasperReports: Removing duplicate values from dataset

I want to print only unique values from a dataset into the list component, avoid开发者_运维知识库ing duplicate values.

How to do it?

P.S. I am using XML as the data source.


Try something like the following when you are selecting nodes in you datasource using X-Path.

/root/*[not(text() = preceding-sibling::*/text())]

It will select unique nodes for a XML structure like bellow.

<root>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node3>Data3</Node3>
</root>


You can group on that value, in your case the Product, grouping will eliminate duplicates.

NOTE: the data should be sorted for grouping to work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜