I use a Jasper as a report engine (using iReport-4.0.0)
My datasource is XML file datasource and use XPath expression when filling the report
For example
Sample Data
<StudentList>
<Student>
<StdntCd>cd11</StdntCd>
<StdntNm>ee11</StdntNm>
<Schl>Schl11</Schl>
<Cty>Cty11</Cty>
</Student>
<Student>
<StdntCd>cd22</StdntCd>
<StdntNm>ee22</StdntNm>
<Schl>Schl22</Schl>
<Cty>Cty22</Cty>
</Student>
</StudentList>
And my XPath expression is that
/StudentList/Student
The issue happened when No data such that
<StudentList>
</StudentList>
My need to show all section of the report without detail (because there is no data)
Although i set “When No Data” property with “All Sections,No Detail”
But still not work
Note
No data is equivalent to the previous XML NOT like that
<StudentList>
<Student></Student>
</StudentList>
In order to avoid this best is to define a
printWhenExpressionfor the detail band.in iReport: click in report inspector on detail band, in properties panel modify
printWhenExpressionto$F{StdntCd} != null: this will only show students that do have a code other thannull.If you utilize the
REPORT_COUNTvariable, you will need to add a custom variable instead:java.lang.IntegerSum$F{StdntCd} == null ? 0 : 10This will allow you all the time the correct output, assuming that the field
StdntCdcan never benullif valid data is provided.If your report runs with a different language than groovy you might need to adjust the expressions.