DrDevice Posted December 21, 2006 Share Posted December 21, 2006 I have ireport 1.2.8 installed on a windows 2003 server, sp1. I have java 5 RE installed, update 10. I can't for the life of me get XML file datasources to work. When i select an xml file datasource, such as the addressbook.xml sample, it tests out okay, but when i provide an xpath expression that I know is valid, such as either / or /addressbook, I get no fields returned. Nothing I can do with any xml file or valid xpath query returns any results.. I have no problems when using a JDBC-ODBC connection to a sql server database, normal fields are returned right away from a valid sql query. What configuration do i not have set up right or what am I doing wrong ? :( Link to comment Share on other sites More sharing options...
rusbob Posted December 21, 2006 Share Posted December 21, 2006 Hi!Setting in iReport - Datasource:1. XML file - path to file2. Set Create a datasource using this expressionand write /rootXML/recordXMLExample my structure XML - file:<rootXML><recordXML><kau>2.2.0.644.7476</kau><begDebStock>0</begDebStock><begCrStock>0</begCrStock><entryDeb>9185.00</entryDeb><entryCr>9185.00</entryCr><endDebStock>0.00</endDebStock><endCrStock>0.00</endCrStock></recordXML>......<rootXML> After you create field on iReport, in Field Desc - write real name the field, kau..... and compiling this report. In source code write:String xmlFileName = "templateEntryAccount.xml"; recordPath = "/rootXML/recordXML"; HashMap hm = new HashMap(); JRXmlDataSource jrxmlds = new JRXmlDataSource(xmlFileName,recordPath); JasperPrint print = JasperFillManager.fillReport( reportFileName, hm, jrxmlds); JasperViewer jv = new JasperViewer(print, true); jv.viewReport(print);It's work very good! Link to comment Share on other sites More sharing options...
DrDevice Posted December 22, 2006 Author Share Posted December 22, 2006 Thanks for the reply ! I didn't realize you have to create the field and you have to put the xml node-name in the description of the field. Thank you for pointing me in the right direction. Link to comment Share on other sites More sharing options...
DrDevice Posted December 22, 2006 Author Share Posted December 22, 2006 double post Post edited by: DrDevice, at: 2006/12/21 19:34 Link to comment Share on other sites More sharing options...
rusbob Posted December 22, 2006 Share Posted December 22, 2006 Hi!I have else one problem...My xml - file has changeable a structure, example:<level0 val="2"><level1 val="2"><level2 val="0"><level3 val="644"><begStockDeb>0</begStockDeb><begStockCr>0</begStockCr><entryDeb>9185.00</entryDeb><entryCr>9185.00</entryCr></level3></level2><level2 val="0"><begStockDeb>0</begStockDeb><begStockCr>0</begStockCr><entryDeb>95.00</entryDeb><entryCr>95.00</entryCr></level2>I concat tag and output them in report....( $F{level1}.length()>-1 ? $F{level1} :"" ) +'.'+( $F{level2}.length()>-1 ? $F{level2} :"" ) +'.'+( $F{level3}.length()>-1 ? $F{level3} :"" ) But, if tag be absent, in report output - null :-(My question how solve a problem to change null on the gap, and how execute grouping.....Thanks!!! 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