Dipping a toe in the cold XSLT water

Ovid on 2005-07-14T00:46:18

In working with the code for Bricolage 2.0, we need a convenient way for Web services to work. SOAP is awful, so we're ignoring it for now in favor of REST. REST is rather easy to use and, unlike SOAP, allows us to generate content that is ridiculously easy to parse. In fact, today I am writing my first XSLT stylesheet. By including a reference to that in the REST response, XSLT aware browsers can browse our object datastore without me having to write a single line of code. In fact, I had started writing code that would allow the user to request HTML instead of XML, but now that I know to include the XSLT link, this is transparent.

After playing around with this for a bit, I discovered a slight bug in my server code just by clicking around through a test database in the browser. Mighty cool! Now I know why XSLT is such a hot technology.


Writing XSLT

Dom2 on 2005-07-14T06:47:19

If you need to author XSLT, I highly using GNU Emacs together with nxml-mode. There really is no better XML authoring environment. It validates as you go, highlighting errors in your file with a red line underneath. And it has completion of valid elements/attributes at the cursor. It rocks.

Funnily enough, it was written by James Clark, who was also one of the main people behind the XSLT spec.

-Dom

Re:

Aristotle on 2005-07-14T22:53:08

XSLT can easily blind someone with its excessive verbosity and the painful lack of string munging (the exact opposite of Perl, I suppose). But the tree manipulation language at the core is elegant and the XPath language underpinning it is deeply beautiful. I’ve been hacking XSLT for a while, and I love it.

I’ve been toying with the idea of using the possibility to easily register extension functions with XML::LibXSLT to make Perl’s string munging available to stylesheets. Of course, that means stylesheets written to take advantage of that would be completely unportable, but it still seems worthwhile for personal stuff or closed systems.