Next post: Graphing Calculator

XSLT Transforms

I've used XSLT transforms for two personal projects recently.

As a software developer, I want to automate away any manual work, and so I often write meta-software that assists with a software project. For my LnzScript project, I write documentation inline with the C++ source code. A Python script then retrieves the documentation out of the code and saves it to an XML file. I chose XML partly because it's in fashion, but also the flexibility gained by storing my documentation in XML has actually been practical -- right now three subprojects written in three different languages (C#, Python, xsl/JavaScript) are retrieving the data.

For viewing the documentation online, I thought it would be fun to use the raw XML file itself and write XSL to transform it into readable xhtml. This is all documentation I've written myself, and so there wasn't a real need for this fancy type of transform. It's fun to literally see the .xml extension in the url, though, and it was a new challenge to write the correct XPath.

See the LnzScript documentation.xml in action here.

Also, there's a software development tool called Runtime Revolution that I've been using for a few years. I wanted to be able to look at its documentation from any computer, without having to first install all of the SDK. I couldn't find its documentation posted anywhere online, and so I decided to find the documentation on my own.

I dug around in its program files, and discovered that the documentation I wanted was stored in hundreds of XML files. How to show these files in a browser? While I could have say written a Python script to look into the XML and output JavaScript files, I realized that this was a perfect time to use an XSLT transform. Here's the result, compatible with IE 6/7 and Mozilla Firefox:


  • Step 1: Download this file, unzip it, and copy the contents into Revolution's "components" folder. (The documentation we care about is under the path "components/help/dictionary".)
  • Step 2: Open "rev_documentation.html" . If you are questioned about "Active Content", click Allow blocked content. You should now see the Revolution dictionary.

What is xsl/xslt? It's a type of xml file that turns one type of xml into another. The Revolution documentation is in xml format, and web browsers render xhtml, so my xslt sheet converts the documentation into something you can see in the browser. If you want to customize the way things are displayed, edit revDictionary.xsl.