Text only | Skip links
Skip links||IT Services, University of Oxford

1. Using TEI XSL

This is a family of XSL stylesheets which are designed to render simple TEI documents. For the purpose of the TEI Consortium, they
  • Implement the processing of ODD files behind Roma to make schemas and documentation
  • … and thus generate the TEI Guidelines in HTML
  • … and transform the TEI Guidelines to LaTeX for typesetting
  • Render TEI Lite documents to
    1. HTML
    2. XHTML
    3. XSL FO (formatting objects, for page makeup)
    4. LaTeX (for typesetting)
The stylesheets have internal documentation, using P&P Software's XSLTdoc system

2. Limitations

These stylesheets only do what were designed to do!
  • They do not provide a rendering of all TEI elements
  • They do not implement all possible values of every rend attribute
  • The different output formats are not always in sync, or give the same result
but they do deal with quite a few common problems.

3. Related stylesheets

We also maintain in XSLT:
  • A simple Docbook to TEI conversion
  • Conversions to and from OpenOffice XML
  • (coming soon) Conversions to and from Word 2007 XML
  • Conversion from TEI P4 to TEI P5

4. Output assumptions

The stylesheets attempt to work in the same way with each of the three supported output formats, but note:
  • The HTML output is designed to work with an associated CSS stylesheet, which takes care of much of the detailed spacing and font work; however, the HTML is in charge of features such as the numbering of sections.
  • The LaTeX output is designed for people who understand how to use existing LaTeX packages and classes; it therefore tries to produce reasonably readable TeX markup, with high-level commands whose effects will be determined by LaTeX (including numbering and spacing).
  • The XSL FO output produces a very detailed specification of the output layout, with all the details of fonts, numbering, vertical and horizontal spacing specified in situ. The FO processor is only responsible for line and page breaking, and hyphenation.

5. Many parameters

There are dozens and dozens of parameters which affect the stylesheet output; you can set values for these by
  • specifying parameter names and values directly in oXygen
  • setting them on a command line
  • constructing a small local stylesheet which imports the public one, and adds overrides

6. Invoking an XSLT transform from oXygen

When you have loaded an XML file, look for the symbol in the menu and press it.

The first time, it will ask you which transformation scenario to use:

7. Simple result

8. Configuring the scenario in oXygen

Look for the symbol. This produces , asking if you want to change the setup. Choose yes, and you see .

9. Changing parameters in oXygen

Now you can supply values for parameters: .

10. Change pageLayout

11. 2 column display

12. Areas of customization

  • Standard page features
  • Layout
  • Headings
  • Numbering
  • Output
  • Table of contents generation
  • Internationalization
  • CSS
  • Tables
  • Figures and graphics
  • Inline Style

Remember that in HTML a lot will be done with CSS and Java

13. Understanding the customization

There are six levels of interaction with the stylesheet family:
  1. setting parameters
  2. overriding templates provided for this purposed (listed in customization guide)
  3. writing templates which implement the empty ‘hooks’ (listed in the customization guide)
  4. adding new templates for elements not covered by the family
  5. providing complete replacements for low-level templates
Always make changes by overriding — never hack the originals!

14. Changing things around a bit

15. On the command line

You might turn test.xml into test.html by typing
xsltproc -o test.html /usr/share/xml/tei/stylesheet/html/tei.xsl test.xml
saxon -o test.html test.xml /usr/share/xml/tei/stylesheet/html/tei.xsl
and then change the result by passing a parameter to specify which CSS file to use:
xsltproc --stringparam cssFile http://localhost/mytei.css --stringparam numberheadings false --stringparam topNavigationPanel true -o test.html /usr/share/xml/tei/stylesheet/html/tei.xsl test.xml

16. Using the a wrapper stylesheet

The simplest example of making a wrapper for the HTML stylesheets is:
<xsl:stylesheet version="1.0">


17. Using the a wrapper stylesheet (2)

Now you can build on it:
<xsl:stylesheet version="1.0">

 <xsl:param name="logoFile">../../logo.png</xsl:param>
 <xsl:param name="logoWidth">60</xsl:param>
 <xsl:param name="logoHeight">60</xsl:param>
 <xsl:param name="cssFile">myTEI.css</xsl:param>
 <xsl:param name="pageLayout">CSS</xsl:param>
 <xsl:param name="outputMethod">xml</xsl:param>
 <xsl:param name="parentWords">The Punch Project</xsl:param>
 <xsl:param name="institution">The University of Punch</xsl:param>

18. Using the a wrapper stylesheet (3)

And start to add your own templates:
<xsl:stylesheet version="1.0">

 <xsl:param name="logoFile">../../logo.png</xsl:param>
 <xsl:param name="logoWidth">60</xsl:param>
 <xsl:param name="logoHeight">60</xsl:param>
 <xsl:param name="cssFile">myTEI.css</xsl:param>
 <xsl:param name="pageLayout">CSS</xsl:param>
 <xsl:param name="outputMethod">xml</xsl:param>
 <xsl:param name="parentWords">The Punch Project</xsl:param>
 <xsl:param name="parentURL">http://tei.oucs.ox.ac.uk/Punch/</xsl:param>
 <xsl:param name="institution">The University of Punch</xsl:param>
 <xsl:template match="tei:hi[@rend='upsidedown']">
  <span class="upsidedown">

19. Organisation of stylesheet files

The stylesheets are divided into four directories:
templates which are independent of output type
templates for making XSL FO output
templates for making HTML output
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 common directory. The tei.xsl does any necessary declaration of constants and XSL keys.

20. Using the XSL FO stylesheets

Each of the available XSL FO engines has some extensions to the Recommendation, and some have limitations; the stylesheets therefore have conditional sections to cater for this. The parameter foEngine can be set to one of the following values
  • antenna (Antenna House processor)
  • fop (Apache FOP)
  • passivetex (TeX-based PassiveTeX)
  • xep (RenderX XEP)

21. Recommendations

  • Use XSLT to make web pages. Easy.
  • If you have LaTeX expertise, convert XML to LaTeX and prepare typeset pages that way
  • If you have a workflow which can accept XSL FO, use it
  • If you need to get Word files:
    • create HTML and load it into Word or OpenOffice
    • convert the TEI XML into OpenOffice using the TEIOO filters

22. PDF generated from LaTeX

23. Loading HTML into Open Office

Date: 2008-07-13
Copyright University of Oxford