XSLT in Action
Posted on November 14th, 2002 in Web Development | Comments Off
People often ask me what I do at work and it’s hard to give a straight answer because I do a lot of different things. Today, I’ll tell you about what I’ve been doing for the past week. To most people this is about as exciting as reading the phone book but this is what I do for a living and it’s exciting to me.
In case you don’t know, XML is an emerging technology that is getting a lot of attention these days. XML and it’s related technologies provide for a way to store and manipulate structured data in text format. XSLT deals with the “manipulate” part and this is what I’ve been learning about this week.
A while ago I was asked to put together a web-based photo album application for our marketing department. I started thinking about whether using XML would be appropriate for the project. I pulled together some images and text for a few sample photo albums and started researching various XML related technologies that could be of use. I eventually settled on using XSLT to produce the output for the photo albums with Xalan-C++ being my XSLT processor. After learning the ins and outs of the XSLT language I ended up with a style sheet that produces decent looking output.
See my XSLT Examples page for the results.
XSLT kind of reminds me of the tag-based directives used by Informix’s WebBlade product from a few years ago. I hated that crap and apparently enough other people also hated it because Informix has ceased to exist as an independent company. XSLT is much better than the WebBlade tags but there are a couple of things I find troubling.
First, variables aren’t exactly variable. Once you’ve assigned a value to a variable you can’t change it! Why didn’t they call them constants instead? On the other hand “params” can change value but only when being passed to another template. This forces many applications (my photo album style sheet included) to use recursion to keep track of “counter variables”. I’m not a big fan of recursion because it’s difficult to understand and the same effect can usually be accomplished through the use of loops. Clever recursive code is almost always a headache to maintain.
But XML and it’s related technologies are still in their infancy so I think we can expect to see many improvements over the coming years.
So… ya. That’s what I’ve been working on this week. The coming weeks will see me writing the PHP code to generate the source XML. Then we’ll have the beginnings of a serious web-based photo album application.



