Jump to content
Changes to the Jaspersoft community edition download ×

newbie: XML data source and iReports


mark5009

Recommended Posts

Hi ..

 

I am trying to get going using iReports 2.0.1 and an XML data source and not having much joy. Any help would be appreciated.

 

The steps I am taking are:

 

1. Data/Connections/New

Select 'foo.xml'

Select "Use the report XPath.."

Test (successful)

 

2. Data/Report Query

Query language = XPath

Enter expression: '/FooReport/header'

Click 'Read Fields'

 

And I get nothing back!

So, I am clearly doing something very basic wrong.

 

Any help grateful accepted.

TIA

 

mark

 

Here is the XML of the report:

 

<?xml version="1.0"?>

<FooReport>

<header>

<UserId>Bob Bobson</UserId>

<SessionId>456789</SessionId>

<Site>Internet</Site>

<Intro>Lorem ipsum dolor sit amet</Intro>

</header>

<body>

</body>

</FooReport>

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I don't think xpath works properly, or at least I had the same problem of you. To fix this:

 

Set the expression instead of using xpath.

Your expression would be:

/FooReport/header

 

Then the xpath query will work.

 

Hope that solves it!

Link to comment
Share on other sites

Thanks, for your prompt help, guys, but I must be thick today .. :)

 

berlim,

 

I tried your suggestion of putting the expression into the data source expression. I then assume that I go into 'Data/Report Query', select 'XPath' and enter a value of '/' as the query? If I do that or explictly set the field name, like '/UserId' I still see nothing in the Fields section.

 

Also, I have 'Auto Retreive Fields' off and am doing a maual fetch. Doesn't make a difference.

 

nitin,

 

Ummm .. what sidebar? I can't seem to get fields from anywhere!

 

Additionally,

 

Here is the bit from the .jrxml file

<queryString><![CDATA[/FooReport/header]]></queryString>

 

And that seems to be okay.

 

Is there a differnce between the 'XPath' and 'xpath2' query languages? I assume that 'XPath' is just 1.0 and 'xpath2' will do both?

 

Thanks again. Still more help needed!

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