junioryy Posted May 22, 2007 Share Posted May 22, 2007 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: 04country: 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 More sharing options...
andreas.daab Posted May 22, 2007 Share Posted May 22, 2007 Use your xml file as datasource. In the field "Create a data source using ths expression" put "/logRecord". Then create a field. Call it e.g. myField and use "logField/@oldValue" as field description. Link to comment Share on other sites More sharing options...
junioryy Posted May 23, 2007 Author Share Posted May 23, 2007 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 More sharing options...
andreas.daab Posted May 30, 2007 Share Posted May 30, 2007 I would do it with java code1. Read the XML-File from your database and save it to a file2. Read the other fields from database and put them into Objects, e.g. Strings or a HashMap.3. Create a JRXmlDataSourceCode:JRXmlDataSource dataSource = new JRXmlDataSource("file.xml", "/logRecord"«»);4. Create a parameter HashMapCode:[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 ObjectCode:[code]JasperPrint jasperPrint = JasperFillManager.fillReport("myreport.jasper", parameters, dataSource);6. Add your parameters ("PARAM1") to your report Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now