XSLT is a language that allows us to transform one XML document into another XML document. We can take a document in TEI and turn into XHTML, for example.
XSLT documents contain set of rules for making the transformation. We call these documents stylesheets, so they are often confused with other stylesheets, such as CSS stylesheets. Unlike CSS, however, XSLT is not used to alter just the presentation, but the actual structure.
XSLT stylesheets defines a list of rules that are executed, and those rules use XPath expression to select elements for processing. For example, say we wanted to do this:
| <text> <title>My Story</title> <para>As the day began…</para> </text> |
|
<html> <h1>My Story</h1><p>As the day began…</p> </html> |
We could use this stylesheet:
<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<html>
<xsl:apply-templates />
</html>
</xsl:template>
<xsl:template match="title">
<h1><xsl:value-of select="."/></h1>
</xsl:template>
<xsl:template match="para">
<p><xsl:value-of select="."/> </p>
</xsl:template>
</xsl:stylesheet>
Don't worry about understanding this example fully; it's mainly here to given an idea what XSLT looks like.
By default, oXygen shows the XHTML file as text in the lower panel, but you can also ask oXygen to open the file in a browser window. To do this:
...and the file will open in a browser
This is a common goal for TEI projects, and since TEI markup is so complex, there is an existing project to develop an "authoritative" set of stylesheets to perform this task. These stylesheets come packaged in oXygen as a default transformation. They appear under the name "TEI HTML" in the list of available transformations.
These stylesheets can accept parameters which affect the output XHTML. The customization guide is available at: http://www.tei-c.org/Stylesheets/teic/customize.xml
As a practice for customization, add the parameter "numberParagraphs" and set it to "true"
(These TEI styesheets are maintained by the TEI consortium and are available online at: http://sourceforge.net/project/showfiles.php?group_id=106328 Look under the selection called "Stylesheets". Information on these stylesheets are available here: http://www.tei-c.org/Stylesheets/teic/)
There is a public archive of TEI stylesheets in the TEI.org wiki at: http://www.tei-c.org.uk/wiki/index.php/Category:XSLT
Practice running XSLT transformations using the marked up materials from day 1.
Practice setting XSLT parameters.
Practice running transformations on TEI files using the stylesheets from the TEI wiki above.