Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:55:28+00:00 2026-05-30T21:55:28+00:00

I have a very simple XML datasource structured like this: <datasource> <row> <column>Some text

  • 0

I have a very simple XML datasource structured like this:

<datasource>
    <row>
        <column>Some text 1</column>
        <column>Some text 2</column>
        <column>Some text 3</column>
    </row>
    <row>
        <column>Some text 4</column>
        <column>Some text 5</column>
        <column>Some text 6</column>
    </row>
    <row>
        <column>Some text 7</column>
        <column>Some text 8</column>
        <column>Some text 9</column>
    </row>
</datasource>

And I want to create a very simple XLS report formatted like this:

-------------------------------------------
| Some text 1 | Some text 2 | Some text 3 |
-------------------------------------------
| Some text 4 | Some text 5 | Some text 6 |
-------------------------------------------
| Some text 7 | Some text 8 | Some text 9 |
-------------------------------------------

I have created a report with the XPath query:

/datasource

And two fields:

$F{row}
$F{column}

with expressions:

row
row/column

respectively.

I have added a crosstab element to the Detail band and have made a few attempts to configure it with different variations of the fields defined above for the row and column grouping options. But the best result I have been able to get is the 1st column value (i.e. “Some text 1” value in the above example).

My questions:

  1. How can I configure the crosstab element to iterate over each row
    element in my datasource and push the column values into the right
    cells as per the example above?
  2. Is the crosstab element the most
    suitable element for this type of task?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:55:29+00:00Added an answer on May 30, 2026 at 9:55 pm

    Ok so I have figured it out and I really cannot pin point any one source as a good point of reference for this stuff. Jasper’s documentation and community contribution is for the most part sparse and dated. I digress. Here is what I did to get it working for iReport 4.5.0 and Jasper 4.5.0:

    1. Create a blank A4 report in iReport.
    2. Edit the document query to select all ‘row’ elements using XPath syntax (i.e. /datasource/row)
    3. Now create a sub dataset by right clicking the document property from your Report Inspector view (i.e. the one with the same name as your .jrmxl file) and selecting Add dataset.
    4. In the wizard select “create new dataset from a connection or datasource”
    5. Select the same XML datasource as your master report and if you have fields or groups you want to pass across select them in the corresponding wizard windows that follow. But the main thing is to select your datasource.
    6. Now you will need to edit the query to select on your column elements. Before doing this, to make life easier, I edited my XML datasource to include a “count” attribute in each row element. You can create your own incrementing count if you like but for me editing the datasource document was the easiest.
      1. So next thing I did was create a field in my master report called “rowCount” and gave it the description expression “@count” so that it would store the count attribute value from each row element.
      2. After that I set up a parameter in my sub dataset with the same name.
      3. Then I configured my sub dataset query to read “/datasource/row[@count=”$P{rowCount}”]/column” so that all column elements were selected for each row.
      4. Next I created a field in the sub dataset called columnValue with the description expression: “text()” to store the text from each column element.
    7. After configuring the sub dataset I dragged a crosstab object into my detail band which prompted the crosstab wizard to show.
      1. In the wizard I selected the sub dataset as its datasource and selected the same connection as the master report.
      2. For the Row and Column group values I just chose $P{rowCount} and $V{COLUMN_COUNT} respectively.
      3. Most importantly I configured the “Data” section to point to my columnValue field and select the measure as “nothing” rather then count or any other calculation. Lastly click finish to create the object.
    8. Next step was to right click the crosstab object in the Report Inspector and select “crosstab data” which bring up a data config window. In here I:
      1. Selected “data is pre-sorted”
      2. In the Dataset Run section at the bottom, in the “Connection/Datasource exp” tab I selected “Use Connection Expression” with the value $P{REPORT_CONNECTION}
      3. In the “Parameters” tab I added:
        • XML_DATA_DOCMENT
        • REPORT_CONTEXT
        • XML_DATE_PATTERN
        • XML_NUMBER_PATTERN
        • XML_LOCALE
        • XML_TIME_ZONE
        • rowCount
      4. I left the “Parameters Map exp” blank.
    9. The last couple of things to do from this point is to hack the XML to remove the row and column group markup which entails removing the following elements from inside the “crostab” JRXML element (including all sub elements of the below):
      • crosstabRowHeader
      • crosstabTotalRowHeader
      • crosstabColumnHeader
      • crosstabTotalColumnHeader
    10. Lastly of all wrap your $P{rowCount} row group bucket expression with java.lang.Integer.parseInt so that it can process the rowCount as an integer.

    So that’s it. For me this is what I need to solve the crosstab / XML datasource / sub dataset conundrum!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple XML file, that looks like this: <Data><Day Num=4197> <Date>270611</Date>
I have a very simple xml file that I would like to create a
I have a very simple Android activity layout like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have the following very simple XML file and I want to quickly parse
i have this very simple download page to get an xml file. the script
I have this very simple python code to read xml for the wikipedia api:
I have some very simple xml and xslt documents, which render in IE8 in
I'm new to Linq to Xml. I have a very simple xml file like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.