xmldatasource and crosstab

Hi all and.. sorry for my english :)
I'm new to jasperreports.
I am starting with a simple report like this

__|C1_|C2_|..|Cm
R1|V11|V12|..|V1m
R2|V21|V22|..|V2m
................
Rn|Vn1|Vn2|..|Vnm

My datasource is a xml file

<db>
<element>
<r></r>
<c></c>
<v></v>
</element>
</db>

I've created a new XML datasource
("Use the report xPath expression to fill the report" radioButton selected)

looking at [url=http://www.jasperassistant.com/forum/viewtopic.php?p=4448&sid=5280fa21e1... I used /db/element as primary query
I've also made a subdataset with /db/element[$P{POSITION}]
POSITION is a java.lang.Integer
I pass $V{REPORT_COUNT}

In this subdataset I've defined the r, c and v fields

I've put a crosstab in summary (I've also tried to put it in detail)
I've used the subdataset with the crosstab, setting r as row group, c as column group and v as detail (function: nothing).
In the crosstab property windows, I've added the POSITION parameter.

The report compiles without problems.
When I try to fill the report (Build->Execute with active connection) the result is a empy page.

I also tried to change the "Connection/Data Source Expression" to "Use a data Source" XML_DATA_DOCUMENT and passing
the xml file like in the xmldatasource example

Map params = new HashMap();
Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream("db.xml"));
params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
...
JasperFillManager.fillReportToFile(fileName, params);

when i fill the report an exception is throw
JRXPathQueryExecuterFactory org.w3c.dom.Document document is null??

What's wrong??
Can you show me a simple example with xmldatasource and crosstab?

Tnx in advance!
alucard__'s picture
Joined: Dec 26 2007 - 7:07pm
Last seen: 15 years 9 months ago

1 Answer:

In case you are in still in need for an answer, have a look at my [url=http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&f... describing a simular problem. The crosstab needs it's own seperate dataset/datasource which can be a copy/reference to the report datasource or a new dataset based on a subset of the reports dataset. You can use Java code in the expression tags.
chriswesdorp's picture
Joined: Mar 7 2008 - 3:35pm
Last seen: 15 years 6 months ago
Feedback
randomness