|
By: David Slonosky
XSLT... I could insert some bad joke here about this not being an acronym for a something or other, but frankly it would have been LAME.
OK, so what is XSLT? Let's say you've been given a bunch of XML data. XML data that is, let's say, the entire play of "Hamlet". In conveniently wrapped XML bits of data. Someone has gone in and organized all the acts together, then all the scenes within each act, then each speaker in each act and also separated out the stage directions. And there it is. All in one big XML file. (If you think such things are impossible, then There are more things in heaven and earth, Horatio, Than are dreamt of in your philosophy. But come; ) And someone says, "You know, I've always admired that Willy Shakespeare boy, but I've never liked that Polonius character. Get me a printout of that script with that Polonius's speeches taken out and do it by five o'clock."
You could sit there with your favourite text editor and do it with the old-fashioned global search and delete method. Or you could apply some XSLT to it and get the whole thing done by lunch, then pretend to edit the rest of the day while secretly you are listening to Miles Davis on your MP3 player and liberally hitting the Boss key in that game no one admits to having on their computer at work. XML is structured text.
Formally structured, which means that it goes beyond loose structuring, which is what you get if you build a Word or FrameMaker template and everyone who gets the template doesn't change it very much and mostly follows your in-house style guide. XML is structured in terms of how elements inside it can be set out (acts and scenes), but can be even more rigidly structured by defining and applying a Document Type Definition (DTD) or XML Schema (XSD file) to it.
So if our copy of hamlet.xml had a DTD or XML Schema attached to it, we could demand (and rightfully so) that there can't be a new act heading popping up in the middle of a soliloquy followed by the rest of the soliloquy. So who cares?
What's wrong with just having hamlet.txt? Well, because XML is structured, and because you can precisely define that structure, you can use Extensible Stylesheet Language Transformations (XSLT) to massage hamlet.
|