At work, I have been working on a bit of functionality to allow the users of our system to fetch quotes from a vendor live in our system. Now, this particular vendor offers an XML API as the one true way to handle all of this. You send them a query crafted in XML and you get back an answer crafted in XML. However, XML is not really human readable or, at least, not human presentable. I had heard of XSLT before and knew that it was a way to transform XML documents, however, I had no opportunity to use it as I have fairly little contact with XML. This seemed like the perfect opportunity to learn and use a tool ideally suited to what I was trying to accomplish so I dug in.

First, before I go any farther, let me say that: I LOVE XSLT! At least, insofar as I can love anything that comes in an XML package. It allowed me to do exactly what I needed and I can already forsee other uses for this.

So, to sum up, this isn't a rant, but XSLT ends up being almost a letdown. When you hear the acronym and see the terminology being slung around, it sounds like there is a great deal more involved. XSLT, though, is basically awk in the twenty-first century. In transformation mode, you basically list a series of templates along with what you would like the output to look like, using special tags to insert values from the current segment. Compare, if you will:

Awk:

$2 ~ /foo/ { print "hi" }
XSLT (forgive the square brackets being used in place of angled; a hazard of Wordpress)
[xslt:template match="foo"]

hi
[/xslt:template]

The idea is somewhat contrived and makes assumptions as to what Awk will regard as a field and line separators. However, the idea is demonstrated: in both cases the "program" (awkinology) or "template" (xsltinology) is a list of rules, each of which is applied to the input. Indeed, the whole sequence is not unlike several attempts made at an XML comprehending Awk. Though, in my opinion, XMLGawk is a little more awkward than XSLT.

One important difference between XSLT and Awk is that, if multiple rules match, Awk applies them all whereas XSLT has a ranking method to decide which rule to apply.
It is not in vain that it is written that "there is nothing new under the sun."