XML datasources

JasperReports allows us to use any well formatted XML document as a datasource. JasperReports uses XPath expressions to traverse the XML documents and extract the data for the report.

Note

XPath is a language used to navigate through an XML document's attributes and elements. More information about XPath can be found at http://www.w3.org/TR/xpath.

For our next example, we'll need an XML file from which we'll read the data. The following XML document will serve this purpose:

<?xml version="1.0" encoding="UTF-8"?> <AircraftData> <aircraft> <tail_num>N263Y</tail_num> <aircraft_serial>T-11</aircraft_serial> <aircraft_model>39 ROSCOE TRNR RACER</aircraft_model> <engine_model>R1830 SERIES</engine_model> </aircraft> <aircraft> <tail_num>N4087X</tail_num> ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.