A TEI Project

XSL stylesheets for TEI XML

Table of contents

1. Introduction

This is a set of XSLT 2.0 specifications to transform TEI XML documents to various forms, including XHTML, LaTeX, XSL Formatting Objects, ePub, plain text, RDF, JSON; and to/from Word OOXML (docx) and OpenOfice (odt). They concentrate on the core TEI modules which are used for simple transcription and ‘born digital’ writing, but adding support for other modules is fairly easy. It is important to understand that they do not:

and should not be treated as the definitive view of the TEI Consortium.

2. File organisation

The stylesheets contain seven directories where most of the work is done:

common2
templates which are independent of output type, used by the other transformations
xhtml2
templates for making HTML output (also used for ePub)
latex2
templates for making LaTeX output
docx
conversion to and from Word OOXML format
odt
conversion to and from OpenOffice ODF format
fo2
templates for making XSL FO output
odds2
processing of TEI ODD files

Within each directory there is usually a separate file for the templates which implement each of the TEI modules (eg textstructure.xsl, linking.xsl, or drama.xsl); these are included by a master file tei.xsl. This also includes a parameterization layer in the file tei-param.xsl, and the parameterization file from the common2 directory. The tei.xsl does any necessary declaration of constants and XSL keys.

There are further directories for other conversions, some which are built on top of the xhtml one above:

bibtex
conversion to BibTeX
docbook
conversion to/from Docbook
dtd
ODD conversion to DTD
epub
conversion to ePub
epub3
conversion to ePub3
html5
conversion to HTML5
json
conversion to JSON
nlm
conversion to NLM
rdf
conversion to RDF (CIDOC CRM)
slides
conversion to LaTeX and HTML slides
tbx
conversion to TBX
tcp
conversion from Text Creation Partnership P4 XML
tite
conversion from TEI Tite to normal TEI P5
txt
conversion to plain text
xlsx
conversion from Microsoft Office spreadsheet format

The final important directory is profiles, which has a set of predefined project starting points, each of which may have a file to.xsl for one or more of the supported output formats (csv, docbook, docx, dtd, epub3, epub, fo, html5, html, ibooks, json, latex, lite, oddhtml, odt, p4, rdf, relaxng, tcp, txt, and xlsx). There may also be a from.xsl to go from the selected format to TEI XML.

For example, to convert TEI to HTML in the default mannner, the user may run profiles/default/html/to.xsl on the selected input file. Other starting points are listed below.

For the brave, there are Linux/OSX command-line shell scripts docbooktotei, docxtotei, odttotei, tcptotei, teitobibtex, teitodocbook, teitodocx, teitodtd, teitoepub, teitoepub3, teitofo, teitohtml, teitohtml5, teitojson, teitolatex, teitoodd, teitoodt, teitopdf, teitordf, teitorelaxng, teitornc, teitoslides, teitotxt, teitoxsd, and xlsxtotei for converting to/from Word, to/from OpenOffice, and to DTD, ePub, HTML, RDF, Relax NG, plain text, W3C schema etc. These are implemented using Ant tasks, which are also available within the oXygen XML editor as part of the TEI framework.

Any other use of the stylesheets, eg by referencing individual modules, requires good understanding of XSL.

3. Documentation of conversions and start points

4. Customization

The TEI stylesheets are designed to be customized, and I will gladly add more parameterization in future. There are currently several hundred things you can set to change the output, described in the Customization Handbook. They are either XSLT variables, or named templates, so you need to understand a little of XSL syntax. If you know a bit more, you can override any of the templates in the style files, but then you are on your own.

The Stylebear web form will construct a XSL file for you, with all the variables configured.

5. Notes on XSLT processors and XSL FO

These stylesheets use XSLT 2.0, and have only been tested with Saxon (from http://saxon.sourceforge.net). An older set of XSLT 1.0 stylesheets are also available, but is not maintained or updated.

It is up to the user to find out how to run the XSLT processor! This may be from within a Java program, from your editor, on the command-line, or inside a web server.

The XSL FO style sheets were developed for use with PassiveTeX (http://projects.oucs.ox.ac.uk/passivetex/), a system using XSL formatting objects to render XML to PDF via LaTeX. They have not been extensively tested with the other XSL FO implementations.

Sebastian Rahtz. Date: 2013-02-24