XSLT beyond <for-each>

Thanks to everyone who came to my XSLT session at Codegarden '10 — it was a blast, and I really appreciate all the great feedback I got from you!

You can grab the slides here and a TextMate bundle with my evil snippets :-)

NOTE: If you’re stuck on Windows, you should be able to use the bundle with E-TextEditor too! Free bonus :-)

Heck, if you want to, you can actually watch a video of the presentation in the Umbraco Video Archive.

Enjoy, and remember lots of garlic for slide #51 :-)


Behind the Scenes

Here’s a little bonus info for XML & XSLT geeks like me: The slides were built with my own custom system; An XML file for defining the slides and an XSLT stylesheet that transforms it into HTML which is then presented using Opera’s "Opera Show" mode. This uses the “projection” media type of CSS, which very easily turns into pages with a couple of simple rules.

Including the code snippets was as easy as copying the code verbatim into a <snippet> element, which I could then handle as any other custom XML element - an example from slide #56:

Actual XML in the slides.xml file:

Rendered view:

Sample Code Snippet

As you can see, there’s even some nifty highlighting going on, which is all handled by templates, just as I’m sort of preaching in the presentation — here’s the template that handles highlighting an attribute:

To make sure the special hi:lite attributes are never accidentally rendered, I include a high priority template for those:

The Post-It™ that tells the language of the code in the snippet is something I implemented very late in the process—but thanks to XSLT & CSS3 it was a walk in the park, to add the language attribute to all <snippet> elements, then a template to add it to the output. And a chunk of CSS to position, rotate & scale it nicely and transparent :-)