Jump to content
JasperReports Library 7.0 is now available ×

display xml data


junioryy

Recommended Posts

hi all experts,

 

may i know how can i display xml data instead of whole xml in the jasper report?

 

for example :

 

<?xml version="1.0" encoding="UTF-8"?>

<logRecord>

<logField

className="my.com.infopro.icba10.kernel.system.domain.Branch"

fieldName="branchType" oldValue="04" newValue="T8"/>

<logField

className="my.com.infopro.icba10.kernel.system.domain.Branch"

fieldName="country" oldValue="AUS" newValue="COL"/>

<logField>

</logRecord>

 

 

What i need is only the fieldname and the value as below:

 

branchType: 04

country: AUS

 

the xml is in java string. so may i know what is the appropriate textfield expression and class type that i need to set?

 

so far i have convert the xml string to an object and pass as parameter to jasper. is it the correct way or got any good solution?.

 

 

Any help and opinion would be highly appreciated.

 

Thanks in advance

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi andreas.daab,

 

really thanks for your reply. however, the xml file is located in DB and i will retrieve it based on the search critea. so currently, im using Database JDBC Connection to retrieve the data..

 

besides the xml file, i also need to display others data such as user info and address.. so, how can i use the xml as datasource and Database JDBC Connection concurrently? is it possible ?

 

Really appreciated if can hear from you again

 

Thank you so much!!

Post edited by: junioryy, at: 2007/05/23 02:34

Link to comment
Share on other sites

I would do it with java code

1. Read the XML-File from your database and save it to a file

2. Read the other fields from database and put them into Objects, e.g. Strings or a HashMap.

3. Create a JRXmlDataSource

Code:

JRXmlDataSource dataSource = new JRXmlDataSource("file.xml", "/logRecord"«»);

4. Create a parameter HashMap

Code:
[code]
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("PARAM1", "value1"«»);

PARAM1 is String in this example, but it can be an instance of every class.

5. Create a JasperPrint Object

Code:
[code]
JasperPrint jasperPrint = JasperFillManager.fillReport("myreport.jasper", parameters, dataSource);

6. Add your parameters ("PARAM1") to your report

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...