Your field
elements do not contain XML path expressions. Try this:
<field name="firstName" class="java.lang.String">
<fieldDescription><![CDATA[DATA/ROW/firstName]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<fieldDescription><![CDATA[DATA/ROW/lastName]]></fieldDescription>
</field>
<field name="code" class="java.lang.Integer">
<fieldDescription><![CDATA[DATA/ROW/code]]></fieldDescription>
</field>
Also, there's a little trick I employ sometimes. Create a wrapper class around JRXmlDataSource
that dumps the contents of the fields as Jasper retrieves them:
package <your package here>;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.data.JRXmlDataSource;
public class MyXmlDataSource extends JRXmlDataSource {
public MyXmlDataSource(String x, String y) throws JRException
{
super(x,y);
}
public Object getFieldValue(JRField jrField) throws JRException {
Object ret = super.getFieldValue(jrField);
System.out.println(ret);
return ret;
}
}
Then, instead of instantiating JRXmlDataSource
, instantiate MyXmlDataSource
instead. This will let you know which elements are being retrieved by Jasper from your XML.