An Example: TEI

Let us take a break now from terminology and see an actual example. The document to format is a Shakespearean sonnet encoded in TEI-XML, a markup language for scholarly documents, shown in Example 8-2. It consists of a header section with title and other metadata, followed by the text itself, which is broken into individual lines of poetry.

Example 8-2. A TEI-XML document
<?xml version="1.0"?> <!DOCTYPE TEI.2 SYSTEM "http://www.uic.edu/orgs/tei/lite/teixlite.dtd"> <TEI.2> <!-- The metadata. TEI has a rich vocabulary for describing a document, which is important for scholarly work. --> <teiHeader> <fileDesc> <titleStmt><title>Shall I Compare Thee to a Summer's Day?</title> <author>William Shakespeare</author> </titleStmt> <publicationStmt> <p> Electronic version by Erik Ray 2003-03-09. This transcription is in the public domain. </p> </publicationStmt> <sourceDesc> <p>Shakespeare's Sonnets XVIII.</p> </sourceDesc> </fileDesc> </teiHeader> <!-- The body of the document, where the sonnet lives. <lg> is a group of lines, and <l> is a line of text. --> <text> <body> <lg> <l>Shall I compare thee to a summer's day?</l> <l>Thou art more lovely and more temperate:</l> <l>Rough winds do shake the darling buds of May,</l> <l>And summer's lease hath all too short a date:</l> <l>Sometime too hot the eye of heaven shines,</l> <l>And often is his gold complexion dimm'd;</l> <l>And every fair from fair sometime declines,</l> <l>By chance or nature's changing course untrimm'd;</l> ...

Get Learning XML, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.