Jaspersoft Studio - Problem with dynamic tables using subreports

0

Hi Community,

I'm facing an issue in Jaspersoft Studio. I have a XML document source formatted as following:

<authors>
    <occurrence index="1">
        <author>
            <name>William</name>
            <surname>Shakespeare</surname>
            <works>
                <occurrence index="1">
                    <work>
                        <title>A Midsummer Night's Dream</title>
                        <year>1595</year>
                    </work>
                </occurrence>
                <occurrence index="2">
                    <work>
                        <title>Hamlet</title>
                        <year>1602</year>
                    </work>
                </occurrence>
            </works>
        </author>
    </occurrence>
    <occurrence index="2">
        <author>
            <name>James</name>
            <surname>Joyce</surname>
            <works>
                <occurrence index="1">
                    <work>
                        <title>Dubliners</title>
                        <year>1914</year>
                    </work>
                </occurrence>
                <occurrence index="2">
                    <work>
                        <title>Ulysses</title>
                        <year>1922</year>
                    </work>
                </occurrence>
                <occurrence index="3">
                    <work>
                        <title>A Portrait of the Artist as a Young Man</title>
                        <year>1916</year>
                    </work>
                </occurrence>
            </works>
        </author>
    </occurrence>
</authors> 

and I have to define 2 different tables in Jaspersoft Studio:

One table is the table of "Authors" where I need to map only one row with name and surname of every author

The second row is the table of "Works" where I need to map for every author its works ("title" and "year").

The result must be like this:

"AUTHOR":

"NAME" "SURNAME"

  • WILLIAM,SHAKESPEARE

"WORKS":

"TITLE" "YEAR"

  • A Midsummer Night's Dream,1595
  • Hamlet,1602

AND

"AUTHOR":

"NAME" "SURNAME"

  • JAMES,JOYCE

"WORKS":

"TITLE" "YEAR"

  • Dubliners,1914
  • Ulysses,1922
  • A Portrait of the Artist as a Young Man,1916

Using subreports I can define the "AUTHORS" tables with one row per table but when I try to retrieve "WORKS" for every author I get an error because I retrieve the list of all the works and not only the works of that particular author.

The Xpath query used for this second table is "/authors/occurrence/author/works/occurrence/work"

Considering that in general I don't know a priori how many works there are in the XML for every author is there a way to retrieve the tables in the way I need?

Thanks

samuele.vigano's picture
Joined: Mar 6 2017 - 4:08am
Last seen: 1 year 5 days ago

0 Answers:

No answers yet
Feedback