Report design is defined in an xml file with a conventional extension *.jrxml. The xml structure is defined in a DTD file and can be downloaded from the sourceforge.
A simplest table report definition can look like this:
01<?xml version="1.0"?> 02
<!DOCTYPE jasperReport 03
PUBLIC "-//JasperReports//DTD Report Design//EN" 04
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> 05
06
<jasperReport name="Simple_Report"> 07
<field name="Name" class="java.lang.String"/> 08
<detail> 09
<band height="20"> 10
<textField bookmarkLevel="2"> 11
<reportElement x="0" y="0" width="100" height="15"/> 12
<textFieldExpression class="java.lang.String">$F{Name}</textFieldExpression> 13
</textField> 14
</band> 15
</detail> 16
</jasperReport>
For a simple example, we will use the following Jasper xml elements:
parameter - represents the definition of a report parameter.
In jrxml file:
<parameter
name="Title" class="java.lang.String">
</parameter>
In *.java file:
Map parameters = new
HashMap();
parameters.put("Title",
"The Pilot Report");
parameters map is further passed to the report filling function.
field - represents the definition of a data field that will store values retrieved from the data source of the report.
In *.jrxml file:
<field
name="Name" class="java.lang.String"/>
In *.java file fields are handled by classes implementing JRDataSource interface.
For the full description of JasperReports xml elements please refer to the Reference.