What does an XSLT stylesheet do?

For the sake of clarity, we are going to be talking very imprecisely and impressionistically about XSLT. We’ll add precision later. At its simplest, an XSLT stylesheet takes an input file (an XML tree structure) and transforms it or changes its form somehow. It does this by taking the input tree, piece by piece, and applying transformation rules to each piece. These rules say what to do with each piece of input. We call these transformation rules "templates", and an XSLT stylesheet is basically a set of templates, each one with a condition of operation (when do I happen?) and its own specific task (what do I do?). These tasks will take place if and only if the conditions of operation are met.

In this slide, we see a very simple XML input on the top-left and a corresponding HTML output on the top-right. The boxes at the bottom of the slide are representations of the templates in an XSLT file: They are the conditions by which the XML input is transformed into an HTML output.

You may notice that some of the stylesheet conditions are not met in the the input document. For example, there is no <emph> in the imput document, so that operation (and it’s corresponding HTML <em> element it would output) is not carried out.

A Gentle Introduction to XSLT slide 01 of 8
© 2012 Syd Bauman, Julia Flanders, and the Women Writers Project This TEI-encoded XML file is available under the terms of the Creative Commons Attribution-ShareAlike 3.0 (Unported) license.