Made some progress on the Documentum-Cocoon stuff over the Christmas break. I’m working on a piece that will allow me to dynamically build charts and graphs based on data stored in the docbase. Here’s what I’ve done and what’s left to do:
Step 1. Figure out how to build a bar chart in SVG
First, I needed to figure out how to build a chart using SVG. I found some Java code that builds charts using SVG but what I was looking to do was build the SVG programmatically using XSLT to transform my source data which will be XML coming from my Documentum Transformer.
I needed something I could use to graphically draw the chart to get me started on the SVG. I downloaded a drawing tool called Sodipodi for this. It worked great. It stores everything as SVG. So all I had to do was draw my chart and save it to get a nice XML file to start with.
Step 2: Create the SVG with XSLT
Now that I had a static SVG file I needed to create XSLT that would take source data XML and transform it into the bar chart SVG. First, I copied my static SVG file into my Cocoon install to make sure it was happy rendering it into JPEG and PNG. It was. Next, I downloaded the Batik binaries. I wanted a tool I could use to quickly view my SVG file as I tweaked it. Batik comes with an SVG viewer called Squiggle. In WSAD, I created a test XML source data file, copied my static SVG file from Step 1 into a new XSLT file, tweaked, and then viewed the results in Squiggle.
The first thing I did was add comments so I could figure out which part of the SVG did what. In Sodipodi I had set every object’s “id” attribute, so correlating the XML to the object it was describing was pretty easy. Adding comments made it easy to rearrange blocks of XML to work how I needed it to in the stylesheet.
The next thing I did was clean up the SVG by rounding off all of the numbers Sodipodi had used for the coordinates of my shapes. Obviously with a design tool everything has got to be very precise, but for what I needed, whole numbers worked just fine and it made the XML easier to look at.
I then figured out the algorithms I’d need to use to figure out how to dynamically size and position the bars and bar legends in the chart.
Finally, I replaced the hardcoded values with XSLT variables. I then updated my source XML data with new values, transformed, and voila: Dynamically generated bar chart.
Step 3: Grab the data from Documentum on a schedule
The data I need to chart is in Documentum. It changes over time. Because it’s historical data I need to get a snapshot from Documentum on a schedule and store the result somewhere. Then, my chart will be built on-demand via a Cocoon pipeline using the data that’s been captured for a given time period.
I already have a pipeline that gets the snapshot from Documentum. All I need to do is execute that pipeline on a schedule and store the result somewhere. I’ve tested out the “cron” feature of Cocoon and it works great. It allows you to execute a pipeline on a schedule. A perfect fit.
Now what I need is to put my snapshot data somewhere. I’m planning on using Xindice. It’s an XML database embedded in Cocoon (you can use a separate Xindice install if you want). My pipeline will pull data from Documentum, transform it (I really only need to store a subset/summarized cut of the data), and store it in Xindice.
To complete my work for this step, I need to look at the XML:DB examples in Cocoon to learn how to stick data in Xindice from a pipeline.
Step 4: Build the chart based on the historical data
Now that I’ve got my historical data summarized and sitting in Xindice, I need to create a pipeline that will query Xindice for the data and transform the query result using the SVG I build in Step 2.
To complete my work for this step, I need to look at the XML:DB examples in Cocoon to learn how to query XML data from Xindice using XPath. The rest should be a piece of cake.
The result
Once this is in place, I’ll have an approach and some reusable code I can use to capture and chart source data from Documentum.