Visualizing RDF with XSLT+SVG is hard, shopping is fun.
I’m trying to create an RDF visualizing application.
As I was digesting my bagel and coffee this morning I noticed Norm Walsh’s RDFTwig documentation explains many of the problems I’ve been dealing with while trying to create this visualizer.
In the RDFTwig doc, Norm talks about the difficulty of processing RDF/XML with XSTL due to RDF/XML’s lack of a true canonical form. Turns out that RDF/XML is extremely flexible… the same RDF relationships or graphs can be represented in near infinite ways using RDF/XML. This is a nice feature for many uses of RDF/XML — not the least of which could be human readability concerns (e.g., you can massage RDF/XML in many ways to make it more approachable to human eyes).
But considering RDF graph relationships can be represented by different attributes (rdf:resource, rdf:nodeID, etc) or elements (child elements from RDF or any other schema) it can be nearly impossible to create a generic XSLT stylesheet which uses the correct XPaths (and axes) to access the data you want for any given RDF/XML document.
In fact, I suspect this truly is impossible.
This was the problem I was faced with this week. Norm’s RDFTwig would have actually been a good solution to the problem… But I discovered RDFTwig after I had already found a solution in the Redland RDF Toolkit.
Turns out that Redland can read RDF data (in XML or other forms) and produce a sort of normalized/canonicalized serialization (in XML or other forms). I don’t believe this normalized form is any standard serialization, but it is, at least, internally consistent… Redland always produces the same type of serialization given a specific processing path.
This is important because I can now predict what the RDF/XML data will “look” like, and it’s much easier to write an XSLT stylesheet against that.
Here’s the stack I’ve chosen to implement the visualizations:
- Redland Objective-C bindings to serialize RDF to “normalized” RDF/XML
- XSLT (powered by libxml+libxslt to transform RDF/XML to SVG
- Latest WebKit nightly (with SVG support built-in) to view the SVG.
- And of course Cocoa (AppKit and Foundation Kit) to deliver the app in a friendly Aqua interface.
I’m getting pretty close.. I just have to pull the pieces together. Along the way, as I’m programming in XSLT, I’m trying to become one with recursion and functional programming — since XSLT is side-effect-free, it’s the only way to do non-trivial programming in XSLT. Here’s a sample svg document (you’ll need WebKit nightly, Opera 9, or Firefox 2 to view this)
Now for some christmas shopping…

1 Comment
Jump to comment form | comments rss [?] | trackback uri [?]