XSL: I love thee, I love thee not

Jump to menu

13 June 2003

Sometimes, usually when I’ve just finished doing something in the manner, I want to do everything with XSL and XML. I even think that I could use the DOM to create my XML and XSL files without angle brackets.

At the moment I’m not using it for anything so ambitious, though. I’m merely trying to transform RSS with it, in two places.

The first is my blogroll (available on my boring start page), which actually works. It takes data from blo.gs at most once an hour, transforms it into XHTML using XSL, and throws that out onto the page, as well as caching the transformed version. I plan to tidy it up, make it work with BlogRolling, and then release it.

The second is in my own RSS feeds. I want to transform that data, on the client side this time, to provide something prettier to look at in the browser. I don’t have this working yet, and it’s what’s holding up the release of Saltshaker, which is what I’m calling my RSS generation script.

I love thee

Because you’re XML
I like XML because it has standard tools to manipulate it. Also, as far as I’m aware there is no SGML parser for ASP/VBcript, so I don’t really have an alternative.
Because you’re involved with XPath

XSL is one more reason to mess about with XPath. I’ll admit that I’m no XPath expert, and again I don’t really follow this stuff, just look it up, but there’s something about XPath that just feels right.

Well, all apart from the stupid namespacing issue in RSS 1.0 feeds. That doesn’t feel right, not one bit.

Because you’re easy to apply
This is how to transform a node with an XSL document: XML.TransformNode(XSL). That’s it.

I love thee not

Because you add complexity
An extra layer’s added with XSL. Instead of, say, loading XML from an ASP page, and turning the bits into a document, I have to load the XML, load the XSL, apply the transformation, and then output it. So now I’ve got to have a valid XML file to load, a working ASP page, and valid and working XSL.
Because you never want to go on dates

Date formatting just can’t be done properly in XSL. Having messed about a bit with variables and xsl:chooses, it all seems a bit inflexible (partly due to the variables problem, below).

Also, some quick thoughts on internal date formats. They should be sortable numerically/alphabetically. There’s no point in putting the weekday name at the front — year first, then month, then day, then weekday, then time, then timezone. And why do we write dates and times in reverse orders?

Because you don’t have variables
Well, XSL does have variables in name at least, but they aren’t variable ! That is, they can be different each time you execute the file, so they are ‘mathematical variables’ , but you can’t change their value, so they aren’t ‘useful variables’ .

(As an aside, À la folie… pas du tout — a.k.a. He Loves Me… He Loves Me Not — is well worth watching. Also, PWEI did a brilliant song called Wise Up! Sucker which contains the lyrics ‘she loves me, she loves me not’ . Funny how these things come back to you when you’re just staring into space. Clearly it’s time to dig out This is the Day, This is the Hour, This is This!.)