开发者

JasperReports: Removing duplicate values from dataset

开发者 https://www.devze.com 2022-12-28 10:30 出处:网络
I want to print only unique values from a dataset into the list component, avoid开发者_运维知识库ing duplicate values.

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

精彩评论

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

关注公众号