A few months ago I started looking at the whole XML and friend technologies for my Goat project. I discovered that XML does not make a good database contained for anything but the most trivial things – on the other hand, Perl’s Data::Dumper is quite good at the job.
And even if it were: what’s the point of XSLT?
In case you haven’t heard of it, XSLT is a Transformation Language: it’s a specific-purpose programming language that’s designed to take XML data, and turn it into something else. One typical example is to turn an XML document into an HTML representation of it, which can be viewed in a browser.
At first, one thing I found interesting about storing your data as XML, is that with the appropriate XSLT it’s very simple to see the state of the application: you get a ‘viewer’ for free, so to speak.
Thing is, if your data is stored as XML, then you must have a set of functions to load it, parse it and turn it into data that’s usable by your application (arrays and structs for C programmers, lists for Lisp programmers, and so on). That’s code you can’t avoid having, even if you can avoid writing it (there are plenty of XML parsing libraries around).
So I have XML data, and a library to read it in my favourite language. What do I need XSLT for? I can just output the HTML, or whatever else I would produce with XSLT, directly with my general-purpose language.
I wrote a Perl filter to output the status of the application in HTML yesterday, which I was using XSLT for before. Turns out the Perl program is almost the same size as the XSLT program (50 lines in Perl, 53 lines in XSLT – I am talking about ‘fair’ lines here, not obfuscated stuff).
So, what would I learn XSLT for? If a specific-purpose language isn’t better than a generic language at its own task, I would tend to think it has no purpose at all.