Jump to content
JasperReports Library 7.0 is now available ×

JRXMLDataSource problem


2005 IR Help

Recommended Posts

By: John Eric Hamacher - badgerduke

JRXMLDataSource problem

2004-12-20 09:49

There was a previous thread on my problem but the suggestions didn't help so I pose it again . . .

 

I am running a simple report off of the following XML:

 

<?xml version="1.0"?>

<CD>

<artist>

<name>gggg</name>

<album hidden="false">

<title>fixed title</title>

<year>gg</year>

<numTracks>ggg</numTracks>

</album>

</artist>

<artist>

<name>B</name>

<album hidden="false">

<title>B</title>

<year>1988</year>

<numTracks>fixed numTracks</numTracks>

</album>

</artist>

<artist>

<name>a</name>

<album hidden="false">

<title>C</title>

<year>1878</year>

<numTracks>fixed numTrack</numTracks>

</album>

</artist>

<artist>

<name>a</name>

<album hidden="false">

<title>a</title>

<year>a</year>

<numTracks>a</numTracks>

</album>

<album hidden="false">

<title>s</title>

<year>s</year>

<numTracks>v</numTracks>

</album>

</artist>

</CD>

 

On my report detail, I want name and year. There should be 4 detail lines, but only the first shows up.

 

JasperReports 0.6.3

Xpath for name: /CD/artist/name

XPath for year: /CD/artist/album/year

Xpath for DataSource: /

 

Be aware I tried the solution in the previous thread and it did not work. As I see it you want the DataSource Xpath to always be the root node so all the fields can refer to the root node.

 

Any thoughts?

 

 

 

 

 

 

By: John Eric Hamacher - badgerduke

JrXmlDataSource - problems with XPath

2004-12-22 06:41

This is a reports. There was a previous thread on my problem a while ago but the suggestions didn't help so I pose it again . . .

 

I am running a simple report off of the following XML:

 

<?xml version="1.0"?>

<CD>

 

<artist>

<name>gggg</name>

<album hidden="false">

<title>fixed title</title>

<year>gg</year>

<numTracks>ggg</numTracks>

</album>

</artist>

 

<artist>

<name>B</name>

<album hidden="false">

<title>B</title>

<year>1988</year>

<numTracks>fixed numTracks</numTracks>

</album>

</artist>

 

<artist>

<name>a</name>

<album hidden="false">

<title>C</title>

<year>1878</year>

<numTracks>fixed numTrack</numTracks>

</album>

</artist>

 

<artist>

<name>a</name>

<album hidden="false">

<title>a</title>

<year>a</year>

<numTracks>a</numTracks>

</album>

<album hidden="false">

<title>s</title>

<year>s</year>

<numTracks>v</numTracks>

</album>

</artist>

 

</CD>

 

On my report detail, I want name and year. There should be 4 detail lines, but only the first shows up.

 

JasperReports 0.6.3

Xpath for name: /CD/artist/name

XPath for year: /CD/artist/album/year

Xpath for DataSource: /

 

Be aware I tried the solution in the previous thread and it did not work. As I see it you want the DataSource Xpath to always be the root node so all the fields can refer to the root node.

 

Any thoughts?

 

 

 

 

 

By: Peter Severin - peter_p_s

RE: JRXMLDataSource problem

2004-12-22 08:47

Using / as the select expression for your data source will produce a single row for your report. So the result you see is normal. If you want to display all the artists in your report you will have to use the "/CD/artist" expression. Make sure that you modify you fields accordingly. For the name it will be simply "name".

 

Best regards,

 

Peter Severin

- JasperAssistant Team

http://www.jasperassistant.com

 

 

 

 

By: John Eric Hamacher - badgerduke

RE: JRXMLDataSource problem

2004-12-22 12:13

OK, that worked.

 

But what if I encounter a situation when I would need multiple DataSources to populate the same report because the XPath at the DataSource wasn't general enough (for instance, I need to access elements outside "/CD/artist" such as "/CD/software" in the same report)?

 

I work with report designers who are not programmers. I'd like to keep the XPath specs as simple as possible for them. It would be easier if the DataSource Xpath could just be "/" and they could specify an entire Xpath string in one place.

Just a suggestion.

 

Thanx.

 

badgerduke

 

 

 

 

By: Peter Severin - peter_p_s

RE: JRXMLDataSource problem

2004-12-22 13:28

Specifying just "/" is not sufficient as there is not enough information on what you want to iterate. You can still refer other elements using relative expressions such as "../software". These expressions are evaluated in the context of the currently iterated node.

 

You can also use an absolute expression such as "/CD/software", but unlike a relative expression, an absolute expression does not take into account the currently iterated node. Thus the result is different.

 

I agree that this syntax is not for non-initiated, but conceptually this is the same approach that is used by XSLT stylesheets, so I don't think it can be simpler.

 

You might also find helpful the xmldatasource sample that is included with JasperReports distribution.

 

Best regards,

 

Peter Severin

- JasperAssistant Team

http://www.jasperassistant.com

 

 

 

 

 

By: John Eric Hamacher - badgerduke

RE: JRXMLDataSource problem

2004-12-22 13:34

Thanx for the help.

 

badgerduke

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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