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 XHTML, to LaTeX, to XSL Formatting Objects, to/from OOXML (docx), to/from OpenOfice (odt) and to ePub format. The files can be downloaded from the Releases area of http://tei.sf.net. They concentrate on the simpler TEI modules, but adding support for other modules is fairly easy. In the main, the setup has been used on ‘new’ documents, ie reports and web pages that have been authored from scratch, rather than traditional TEI-encoded existing material.

There is a change log file available.

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.

2. File organisation

The main stylesheets are divided into four directories:

common2
templates which are independent of output type
fo2
templates for making XSL FO output
xhtml2
templates for making HTML output
latex2
templates for making LaTeX output

Within each directory there is 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 special-purposes conversions:

bibtex
conversion to BibTeX
docbook
conversion from Docbook
docx
conversion to and from Word OOXML format
dtd
ODD conversion to DTD
epub
conversion to ePub
html5
conversion to HTML5
json
conversion to JSON
nlm
conversion to NLM
odds2
processing of TEI ODD files
odt
conversion to and from OpenOffice Writer format
rdf
conversion to RDF
relaxng
ODD conversion to RELAXNG
rnc
ODD conversion to RELAXNG (compact)
slides
conversion to LaTeX and HTML slides
tbx
conversion to TBX
tcp
conversion from TCP P4 XML
tite
conversion from TEI Tite
txt
conversion to plain text
xlsx
conversion from Microsoft Office spreadsheet format
xsd
ODD conversion to W3C schema

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 docxtotei, odttotei, teitodocx, teitodtd, teitoepub, teitoepub3, teitohtml, teitoodt, teitordf, teitorelaxng, teitornc, teitotxt, and teitoxsd 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 generic 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. XSLT processors

These stylesheets use XSLT 2.0, and have only been testd Saxon (from http://saxon.sourceforge.net). XSLT 1.0 stylesheets are also available, but will not be further maintained. 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.

Sebastian Rahtz. Date: 2012-07-12