XML technologies / XML / XML in a Nutshell / XML as a document format / TEI
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
The Text Encoding Initiative (TEI) is an XML application, originally an SGML application, developed for marking up classical literature such as Virgil’s Aeneid or the collected works of Thomas Jefferson. TEI is an outstanding example of a narrative-oriented DTD. Designed for scholarly analysis rather than casual reading or publication, it includes elements not only for common document structures such as chapters, scenes, and stanzas, but also for typography, grammatical structure, illustration placement on the page, and more. These details are unimportant to most readers but essential to TEI’s scholarly audience. For many academic purposes, two Aeneid manuscripts are not necessarily identical. Transcription errors and corrections made by different medieval monks can be crucial.
The following code example uses TEI’s Lite version, a subset containing only the most common tags. Its content comes from this work, "XML in a Nutshell". A fully TEI-encoded copy of the manuscript would be much longer, but this simple example demonstrates the basic features of most TEI documents representing books. TEI can also be used for plays, poems, missals, and virtually any other written literary form.
<?xml version="1.0" encoding="ISO-88591" standalone="no"?>
<!DOCTYPE TEI.2 SYSTEM "xteilite.dtd">
<TEI.2>
<teiHeader>
<fileDesc>
<titleStmt>
<title>XML in a Nutshell</title>
<author>Harold, Elliotte Rusty</author>
<author>Means, W. Scott</author>
</titleStmt>
<publicationStmt><p></p></publicationStmt>
<sourceDesc><p>Früher Manuskriptentwurf</p></sourceDesc>
</fileDesc>
</teiHeader>
<text id="HarXMLi">
<front>
<div type='toc'>
<head>Inhaltsverzeichnis</head>
<list>
<item>Einführung in XML</item>
<item>XML als Dokumentformat</item>
<item>XML im Web</item>
</list>
</div>
</front>
<body>
<div1 type="chapter">
<head>Einführung in XML</head>
<p></p>
</div1>
<div1 type="chapter">
<head>XML als Dokumentformat</head>
<p>XML ist vor allen Dingen ein Dokumentformat. Es war immer für Webseiten, Bücher, wissenschaftliche Artikel, Gedichte, Kurzgeschichten, Referenzhandbücher, Anleitungen, Lehrbücher, Plädoyers, Verträge, Gebrauchsanweisungen und andere Dokumente gedacht, die von Menschen gelesen werden. Sein Einsatz als Syntax für Computerdaten in Anwendungen wie Bestellabwicklung, Objektserialisierung, Datenbanken sowie elektronischen Datenaustauschsystemen ist eigentlich nur ein glücklicher Zufall.</p>
<div2 type="section">
<head>Das Vermächtnis von SGML</head>
<p></p>
</div2>
<div2 type="section">
<head>TEI</head>
<p></p>
</div2>
<div2 type="section">
<head>DocBook</head>
<p>DocBook ist eine SGML-Anwendung, die für neue Dokumente, jedoch nicht für alte entworfen wurde. Es ist besonders bei Computer-Dokumentationen gebräuchlich. Verschiedene O'Reilly-Bücher wurden in DocBook geschrieben, einschließlich <bibl><author>Norm Walsh</author>s <title>DocBook: The Definitive Guide</title></bibl>. Ein Großteil des Texts des Linux Documentation Projects (<abbrexpan='Linux Documentation Project'>LDP</abbr>) ist in DocBook geschrieben.</p>
</div2>
</div1>
<div1 type="chapter">
<head>XML im Web</head>
<p></p>
</div1>
</body>
<back>
<div1 type="index">
<list>
<head>INDEX</head>
<item>SGML, 89</item>
<item>DocBook, 95-98</item>
<item>TEI (Text Encoding Initiative, 92-95</item>
<item>Text Encoding Initiative, Siehe TEI</item>
</list>
</div1>
</back>
</text>
</TEI.2>Code example: A TEI document
The root element of this and all TEI documents is TEI.2. This root element always has two parts: a header represented by a teiHeader element, and the document’s actual content, represented by a text element. The header contains information about the source document, such as the precise medieval manuscript from which the copy was made, its encoding, descriptive keywords, and so on.
The element text itself has three parts:
- Front matter in the
frontelement Front matter includes the preface, table of contents, dedication page, and cover images. Each part is represented by a
divelement with atypeattribute whose value identifies it as a table of contents, preface, title page, and so on. Each part contains further elements forming its content.- Main body of the work in the
bodyelement The body contains the chapters, acts, and similar divisions making up the document. Each is represented by a
div1element with atypeattribute identifying this part as a volume, book, part, chapter, poem, act, and so on. Everydiv1element has a child elementheader, giving the title of the volume, book, part, chapter, and so on.- Back matter in the
backelement Back matter includes the index, glossary, and so on.
These divisions can be subdivided further: div1 elements can contain div2 elements. div2 elements can contain div3 elements. div3 elements can contain div4 elements; this can continue down to div7. Every work has a smallest unit, however. This unit contains paragraphs represented by p elements for prose, or lg elements for stanzas of poetry. Stanzas are further divided into individual lines represented by l elements.
Both lines and paragraphs contain mixed content: ordinary text whose parts may be marked up further to indicate words or characters that are personal names (name), corrections (corr), illegible (unclear), misspelled (sic), and so on.
This structure closely reflects the actual documents encoded in TEI. The same applies to most narrative-oriented XML applications handling reasonably generic documents. TEI is an exceptionally clear example of a typical XML document structure.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top