ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Generating Database Server-Side Cross Tabulations
Subject:   Crosstabs are the playground for XML
Date:   2003-12-08 12:11:53
From:   anonymous2
IMHO, Crosstabs can easily be done by XML. XML is very flexible at rows, columns, ...


The only way is how to create the XML.


I personally prefer Cocoon to do this. I'm an Open Source user but Cocoon runs as a servlet on Tomcat, so it's available for Windows.


I give a simple example from the Cocoon User Guide:


<page xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
<query name="department" >
select id,name from department_table
</query>
<execute-query>
<query name="employee">
select id,name from employee_table where department_id =
<ancestor-value
sql:name="id" sql:level="1"/>
</query>
</execute-query>
</execute-query>
</page>



This would result in something like this:


<page xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<rowset nrofrows="2" name="department"
xmlns="http://apache.org/cocoon/SQL/2.0">
<row>
<id>1</id>
<name>Programmers</name>
<rowset nrofrows="2" name="employee">
<row>
<id>1</id>
<name>Donald Ball</name>
</row>
<row>
<id>2</id>
<name>Stefano Mazzocchi</name>
</row>
</rowset>
</row>
<row>
<id>2</id>
<name>Loungers</name>
<rowset nrofrows="1" name="employee">
<row>
<id>3</id>
<name>Pierpaolo Fumagalli</name>
</row>
</rowset>
</row>
</rowset>
</page>


Glue this together with some XSLT, and you have your report.


More info: http://cocoon.apache.org


yves.vindevogel@implements.be




1 to 1 of 1
1 to 1 of 1