TEI Boilerplate: Displaying a facsimile beside a transcription

Charles Riondet, Inria

The TEI Boilerplate is a light framework to transform TEI P5 documents with a minimal XSLT stylesheet and present them in a browser, styled with CSS and Javascript. It has been developed by John Walsh, Grant Simpson and Saeed Moaddeli, from Indiana University.

The aim of this solution is to display directly the XML file, skipping the transformation in HTML. The usefulness of such a solution is obvious in order to have a rapid and clear human-readable version of a TEI document. However, TEI Boilerplate can also be a basis for more complex transformations and the production of extensive digital editions.

We would like to show here how we could use the TEI Boilerplate framework to visualize in the same page the edition of a manuscript and the digital image of the original document.
There are several ways to achieve the same result (or even an even more fancy result using elaborate Javascript instructions). Here is one of the simplest, which also gives a few hints of how the users could customize TEI Boilerplate according to their needs with average or even low programming skills.

The principle of TEI Boilerplate customization is very simple: the user can add any constraint in style instruction in two empty files: content/custom.xsl for XSLT processing and CSS/custom.css for styling. Here, we will use mainly the CSS file, but a minor changes in the XSLT templates can be done before.

Page breaks and facsimiles (optional)

What is follows a <pb/> corresponds to the content of a page. The image is associated to the  <pb/> element. TEI boilerplate rightly requires the use of the  @facs attribute to point to the URL of the image.

 <pb facs="images/image1.png" n="1"/>

If you prefer to refer to your images in a <facsimile> element, you must modify an XSL template in the file content/teibp.xsl. But to make sure you know exactly the changes you made, I suggest that you copy the template in the file content/custom.xsl and make the change here.

The template to modify is called pb-handler :

<xsl:template name="pb-handler">
 <xsl:param name="n"/>
 <xsl:param name="facs"/>
 <xsl:param name="id"/>

 HERE, IT'S "TEI/facsimile/surface/graphic/@url"-->
 <xsl:variable name="facsUrl" select="//tei:surface[concat('#', @xml:id) = $facs]/tei:graphic/@url"/>
 <span class="-teibp-pageNum">
 <!-- <xsl:call-template name="atts"/> -->
 <span class="-teibp-pbNote">
 <xsl:value-of select="$pbNote"/>
 <xsl:value-of select="@n"/>
 <xsl:text> </xsl:text>
 <span class="-teibp-pbFacs">
 <a class="gallery-facs" rel="prettyPhoto[gallery1]">
 <xsl:attribute name="onclick">

<!-- replace the parameter $facs with the created variable $facsUrl -->

<xsl:value-of select="concat('showFacs(',$apos,$n,$apos,',',$apos,$facsUrl,$apos,',',$apos,$id,$apos,')')"/>

 <img alt="{$altTextPbFacs}" class="-teibp-thumbnail">

<!-- Replace also the value of the html attribute @src ( which is @facs), by the variable $facsUrl -->

<xsl:attribute name="src">
 <xsl:value-of select="$facsUrl"/>

CSS styling


To display side by side the transciption and the image, CSS instructions must be add in the custom.css file (CSS/custom.css)
The first widen the page.

 html {
 width: 90%;

Here, you shift the TEI boilerplate toolbox in the right corner of the page, or make it invisible

 #teibpToolbox {
 /* shift the toolbox in the right corner of the page */
 /* make the toolbox invisible */

Then, you can enlarge the image and make it float next to the text

 .-teibp-thumbnail {
 max-height: 1000px;

The following will delete the margin of the whole element containing the page number and the image, and align the tops of the transcripton and the facsimile.

 margin: 0em 0px;

Here, you can make changes to the way the page number is displayed.



These changes are very basic but efficient, and abides to the philosophy of TEI Boilerplate, that is to “largely preserve the integrity of the TEI document” (http://teiboilerplate.org/). For more elaborate CSS instructions, you can find a lot of documentation on websites such as http://www.csszengarden.com/.

Download the TEI Boilerpalte on Github : https://github.com/GrantLS/TEI-Boilerplate
TEI document kindly provided by Magdalena Porst (FHP Potsdam).
Images from :
Institut national de recherche en informatique et en automatique (INRIA, Paris FR) . (2016). Journal intime de Leonore Alt [Corpus]. Disponible sur www.ortolang.fr : http://hdl.handle.net/11403/leonore-alt

From TEI-XML to TXM, HTML and back

XSL Style Sheet – Strategy for an Import into TXM

Representations of the Other in the British, French and German Discourse on Europe: A Corpus-Based Contrastive Discursive Analysis

Naomi Truan (Université Paris-Sorbonne / Freie Universität Berlin)

The purpose of this article is to present a successful strategy to import the corpus on which my PhD project is based into the open source software TXM. If you still do not know TXM, click on the link! This software, developed at the Ecole Normale Supérieure (Lyon, France), is open source, regularly updated, and offers a wide range of textometric queries (among them cooccurrences and concordancies, but also many more).

The corpus is delivered with the TEI-XML files and two Stylesheets for the import and the conversion/visualisation in an HTML file (like new shampoos: 2-in-1!). The complete version of this document (with figures and two appendixes) is also to be found on the ORTOLANG server as a PDF document on my workspaces: French, English, German.

As a student in German Studies (focussing mainly on Literature, Philosophy, History, and Translation), I had no prior experience in the huge – but magnificent – world of Computational Linguistics. I discovered it through my PhD in Corpus Linguistics and thanks to the help of Laurent Romary and the TXM team (especially Serge Heiden, Alexey Lavrentev, and Bénédicte Pincemin). Thus, this article is not only here to show you how it works, but also to tell you: Yes, you can! Also with no idea on Computational Linguistics, you can acquire and develop your own strategies to make sense of these weird languages computer engineers work with.

My PhD thesis, entitled “Representations of the Other in the British, French and German Discourse on Europe: A Corpus-Based Contrastive Discursive Analysis”, relies on a qualitative and quantitative linguistic analysis of parliamentary debates in three European countries. You can find the corpora and their accurate description on ORTOLANG: French, English, German.

The corpus has been manually annotated according to the TEI Guidelines. If you wish to consult how the corpus was annotated, please see the document entitled “Corpus Annotation” on the ORTOLANG server (links above).

I – Import into TXM

To import the XML-TEI files into TXM, you have to follow the steps of an “Import TEI générique conservateur” and to select the Import XML/w +CSV. 

You have to put all the TEI-XML files into one folder and to add a file named import.properties (with no extension such as .doc, .pdf), in which you write ignoredelements=note|bibl. This way, the statistics of the corpus in TXM will not take into consideration (ignore) the TEI-XML tags <note> and <bibl>.

Then click on “Sélectionner le répertoire des sources” and select the corresponding folder. Please note that for your first import, the import.xml file, which is created during the import, will not be in the folder. If you happen to modify the TEI-XML files, the import.xml file will be recreated at each import.

In “Dossier des sources”, you can add information on the corpus. If you use the corpus I annotated for you own research project, I kindly ask you to refer to it in this section, for instance with following mention: Naomi Truan 2016 – CC BY 4.0.

The “Police d’affichage” depends on your personal taste and does not affect the import at all.

In the section “Langue principale”, do not forget to tick “en” for English, “de” for German, and “fr” for French if you wish to have the corpus syntactically annotated with TreeTagger (the tutorial for installing TreeTagger on TXM is here).

The “Paramètres du segmenteur lexical” do not need to be changed.

For the “Feuille XSL d’entrée”, please use the style sheet in an XSL format provided along with the TEI-XML files, freely adapted from txm-filter-teip5-xmlw-preserve.xsl.

“Editions” and “Commandes” do not need to be changed.

The import of the corpus can begin; you can now visualise the metadata of the corpus by clicking on the information icon.

Please note that the first “Propriétés des unités lexicales” (body, desc, incident, quote, seg) are not reliable; the given numbers do not correspond to anything in the corpus.

On the text level and on the utterance level, though, the information is fully accurate, so that the following metadata enable correct partitions of the corpus according to these variables: date, government, id, party, party-type, position, role, sex, who-party, who-party-type, who-position, who-role, who-sex.

II – HTML Visualisation of the Corpus with the XSL Style Sheet

I will now comment on the XSL Style Sheet, which can be used for the import into TXM (see Part I), but also to enable the visualisation of the corpus as a whole in an HTML-format. On the ORTOLANG server, you can find it under Content > UK TEI-XML Files, or here.

In the XSL Style Sheet, information in green such as <!– Corpus of British Parliamentary Debates –> does not impact on the XSL Style Sheet but simply provides information to guide the reader.

If you open the XSL Style Sheet and the XML Style Sheet together in oXygen XML Editor, and click, within the XML Style Sheet, on the red button on your right, then oXygen XML Editor will automatically run the Style Sheet and open the corpus in an HTML-format in your browser (like a webpage).

Alternatively, and if you have not proceeded to any changes in the corpus, just double-click on the “HTML file UK – Style sheet (2)”, which will automatically open in your browser as well. The procedure described above is necessary only if you wish to encode other tags or to visualise them differently (for instance, if you wish to see the <quote> tags in orange rather than in red) or if you add new tags in the corpus (for instance, if you notice a missing <quote> tag in one of the TEI-XML files of the corpus).

You can then scroll down through the corpus. It enables you a quick search (for instance through ctrl F for people not familiar with TXM, which offers much more queries in this regard) and a quick visualisation (for instance if you feel you have a better impression of the length of an utterance by seeing it on a webpage – how many lines? – rather than counting text units).

The corpus begins with general information, such as: Number of Incidents, Number of Turns, Number of Speakers, Number of Opposition Members, Number of Majority Members. In this regard, I strongly advise to rely on the statistics provided by TXM rather than on the XSL Style Sheet, which appears to be sometimes misleading. For instance, it counts seven Plaid Cymru Members but reports four names, which is inconsistent (there are, actually, fourPlaid Cymru Members):

Plaid Cymru Members: DAFIS – LLWYD – THOMAS – WIGLEY
Number of Plaid Cymru Members: 7
Number of Turns of Plaid Cymru Members: 7

This is it! Normally, every time you adjust the corpus (correct a typo, do some minor changes, rename a speaker, etc.), the HTML version will follow, enabling you to visualise the last version corpus very quickly and to search through it. At the same time, you can re-import the corpus into TXM by following the previous steps. If you do not rename the corpus, TXM will automatically ask you if you wish to replace the existing corpus. By clicking “yes”, you will update the corpus.

You now can see how to visualise (i.e. make nice!) your corpus through an XSL Style Sheet and an XML Style Sheet especially designed for the purposes of your own research. The Style Sheets can be adapted for every type of corpus following the TEI Guidelines. Thus, it should not be seen as a model, but rather as an example suitable for TXM.

Please feel free to contact me for any question regarding TXM, TEI, XML and HTML formats, but also Corpus Linguistics, Cognitive Linguistics, or Political Discourse! I cannot promise you to be able to answer every technical concern, but I will try my best (and can also forward your question(s) to people who know more than I do): Naomi.Truan@paris-sorbonne.fr. Any comment will be much appreciated!