Creating Jasper Reports In (iReport) Using XML As Data Source

Posted on by By admin, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 1

This blog will teach how to create Jasper Reports using iReport, the data source to be used is XML and then publish it on Jasper servcer

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Click Here to Free Download

  1. Run iReport; it will open showing a Welcome Window, as shown in the following screenshot:

Jasperreport XML data source

2.  DataBase (DataSource ) Connection :

a.)  Click On Datasource button

Jasperreport XML data source 2

b) Click On new button

Jasperreport XML data source 3

C) Select XML datasource

Jasperreport XML data source 4

d) A new window named XML file datasource will open, as in the following

Jasperreport XML data source 5

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Grab The 30 Days Free Trail

e) Enter AddressBook (you can give the name of your choice also) as the name for your new connection for the XML datasource in the text box beside the Name text field  & Click the Browse button to browse to the addressbook.xml file located in the E:/ in my system. Select the Use the report XPath expression when filling the report option in the XML file datasource window,

Jasperreport XML data source 5

f) Now click on “TEST” for testing the connection

3. Creating The Report  :  Open a new report and then go to “query browser”,choose the query language from drop down list as “xpath.” The text area below the Query language drop-down list will split into two parts. The left part  shows the actual XPath expression, whereas the   right part shows XML nodes

Jasperreport XML data source 7

4. In the XML nodes right click on the name child of the person node,select “add node as field”,similarly for phone child of person node also.

Jasperreport XML data source 8

5. Double-click on the Fields node in the Report Inspector window on the left of your report. The Fields node will expand to show the fields name, phone.

Jasperreport XML data source Query

Drag-and-drop the name and phone field from the Fields node into the Detail section of your report.

6. Switch to the Preview tab and you will see your report The result should be similar to the below

Jasperreport XML data source 10

7. Publishing the report to the jasper server

a) Creating data adapter :

a.)    Creating Data Adapter :  To use flat files as a datasource (like  XML  files) you need to use DataAdapters in Jasperserver instead of regular datasources. We can create them manually in the server (it’s just an XML file). Data Adapter is a way to define a source for Jasper Reports using a   configuration file,(act as the bridge between data source and jasper reports while publishing the jasper report on Jasper Server).

xmlAdapter.xml

Jasperreport XML data source 11

<filename>repo:/reports/interactive/xmlData</filename>  – > here xmlData is the name of the xml    file(addressbook.xml) which we have to add again to the Jasper Server.(I have added this file in this location “repo:/reports/interactive/”.

b) We need to add XML datasource to server also

c) Adding xmlAdapter To The Properties attribute of Report.

Property Name : net.sf.jasperreports.data.adapter

Property Value : repo:/reports/interactive/xmlAdapter

 

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Get your 30 Days Trail Version

Note: By default xpath or xpath2 language will not come in jasper server,for this you need to do three things…

  1. Copy jasperreports-extensions-3.5.3.jar from /ireport/modules/ext to JasperReports Server/jasperserver-pro/WEB-INF/lib/jasperreports-extensions-3.5.3.jar
  2. Add the following line to /jasperserver-pro/WEB-INF/classes/jasperreports.properties

net.sf.jasperreports.query.executer.factory.xpath2=com.jaspersoft.jrx.query.JRXPathQueryExecuterFactory

  1. Restart Tomcat
logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

I created the jar with the fonts but when I went up the acipplation on a linux server, can not generate a report. It gives the following error:12:47:07,248 ERROR [stderr] (http 0.0.0.0-8443-2) Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.io.IOException: Problem reading font data.12:47:07,249 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontFace.(SimpleFontFace.java:109)12:47:07,250 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontFace.(SimpleFontFace.java:129)12:47:07,250 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(SimpleFontFace.java:68)12:47:07,251 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:99)12:47:07,251 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:261)12:47:07,252 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:232)12:47:07,253 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:193)12:47:07,256 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:162)12:47:07,256 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56)12:47:07,257 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)12:47:07,261 ERROR [stderr] (http 0.0.0.0-8443-2) at net.sf.jasperreports.engine.util.JRStyledTextParser.(JRStyledTextParser.java:83)12:47:07,261 ERROR [stderr] (http 0.0.0.0-8443-2) 36 more