Jump to content
We've recently updated our Privacy Statement, available here ×

XML Datasource not working ?


DrDevice

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi!

Setting in iReport - Datasource:

1. XML file - path to file

2. Set Create a datasource using this expression

and write /rootXML/recordXML

Example 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

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

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...