<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title type="main">TEI by Example</title>
        <title type="sub">Module 8: Customising TEI, ODD, Roma</title>
        <author xml:id="RvdB">Ron Van den Branden</author>
        <editor xml:id="EV">Edward Vanhoutte</editor>
        <editor xml:id="MT">Melissa Terras</editor>
        <sponsor>Association for Literary and Linguistic Computing (ALLC)</sponsor>
        <sponsor>Centre for Data, Culture and Society, University of Edinburgh, UK</sponsor> 
        <sponsor>Centre for Digital Humanities (CDH), University College London, UK</sponsor>
        <sponsor>Centre for Computing in the Humanities (CCH), King’s College London, UK</sponsor>
        <sponsor>Centre for Scholarly Editing and Document Studies (CTB) , Royal Academy of Dutch Language and Literature, Belgium</sponsor>
        <funder>
          <address>
            <addrLine>Centre for Scholarly Editing and Document Studies (CTB)</addrLine>
            <addrLine>Royal Academy of Dutch Language and Literature</addrLine>
            <addrLine>Koningstraat 18</addrLine>
            <addrLine>9000 Gent</addrLine>
            <addrLine>Belgium</addrLine>
          </address>
          <email>ctb@kantl.be</email>
        </funder>
        <principal>Edward Vanhoutte</principal>
        <principal>Melissa Terras</principal>
      </titleStmt>
      <publicationStmt>
        <publisher>Centre for Scholarly Editing and Document Studies (CTB) , Royal Academy of Dutch Language and Literature, Belgium</publisher>
        <distributor>Centre for Scholarly Editing and Document Studies (CTB) , Royal Academy of Dutch Language and Literature, Belgium</distributor>
        <pubPlace>Gent</pubPlace>
        <address>
          <addrLine>Centre for Scholarly Editing and Document Studies (CTB)</addrLine>
          <addrLine>Royal Academy of Dutch Language and Literature</addrLine>
          <addrLine>Koningstraat 18</addrLine>
          <addrLine>9000 Gent</addrLine>
          <addrLine>Belgium</addrLine>
        </address>
        <availability status="free">
          <p>Licensed under a <ref target="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution ShareAlike 3.0 License</ref>
                    </p>
        </availability>
        <date when="2010-07-09">9 July 2010</date>
      </publicationStmt>
      <seriesStmt>
        <title>TEI By Example.</title>
        <editor>Edward Vanhoutte</editor>
        <editor>Ron Van den Branden</editor>
        <editor>Melissa Terras</editor>
      </seriesStmt>
      <sourceDesc>
        <p>Digitally born</p>
      </sourceDesc>
    </fileDesc>
    <encodingDesc>
      <projectDesc>
        <p>TEI By Example offers a series of freely available online tutorials walking individuals through the different stages in marking up a document in TEI (Text Encoding Initiative). Besides a general introduction to text encoding, step-by-step tutorial modules provide example-based introductions to eight different aspects of electronic text markup for the humanities. Each tutorial module is accompanied with a dedicated examples section, illustrating actual TEI encoding practise with real-life examples. The theory of the tutorial modules can be tested in interactive tests and exercises.</p>
      </projectDesc>
    </encodingDesc>
    <profileDesc>
      <langUsage>
        <language ident="en-GB">en-GB</language>
      </langUsage>
    </profileDesc>
    <revisionDesc>
      <change when="2020-06-15" who="#RvdB">proofing corrections</change>
      <change when="2020-06-11" who="#RvdB">revision</change>
      <change when="2020-04-30" who="#RvdB">updated to Pure ODD + RomaJS</change>
      <change when="2010-07-13" who="#RvdB">
        <list>
          <item>added distinction <gi>gi</gi> — <tag>gi scheme="..."</tag> — <gi>tag</gi>
                    </item>
          <item>final spellcheck</item>
        </list>
      </change>
      <change when="2010-07-09" who="#RvdB">release</change>
      <change when="2008-11-05" who="#RvdB">
        <list>
          <item>updated to TEI P5-1.2.0 + Roma 3.5 (04/11/2008)</item>
          <item>corrected errors + typos</item>
        </list>
      </change>
      <change when="2008-08-21" who="#RvdB">
        <list>
          <item>corrected typos</item>
          <item>elaborated on didactic motivations for some choices in the tutorial</item>
        </list>
      </change>
      <change when="2008-08-19" who="#RvdB">replaced <title level="m">Alice’s Adventures Under Ground</title> example with <title level="m">Alice’s Adventures in Wonderland</title> due to copyright concerns with the images</change>
      <change when="2008-08-01" who="#RvdB">revisions</change>    
      <change when="2008-07-15" who="#RvdB">creation</change>
    </revisionDesc>
  </teiHeader>
  <text xml:id="TBED08v00" type="tutorials">
    <body>
            <div xml:id="minimal">
        <head>Starting from a Minimal Schema</head>
        <p>If you point your browser to <ptr target="https://roma.tei-c.org/"/>, following screen should appear: 
          <figure xml:id="figure3">
            <graphic url="../../../images/tutorials/TBED08v00/romaStart.png"/>
            <head type="legend">The start screen of Roma.</head>
          </figure>
        </p>
        <p>This is the start screen for new customisations, offering you a choice between two options:
          <list rend="bulleted"> 
            <item>
                            <q>Select ODD</q>: start creating a customisation from one of the <soCalled>official</soCalled> TEI customisations</item>
            <item>
                            <q>Upload ODD</q>: start creating a customisation from an existing ODD file on your file system</item>
          </list>
        </p>
        <p>For the purpose of this tutorial, we’ll set out from a minimal customisation. Open the dropdown list and select the <q>TEI Minimal (customize by building TEI up)</q> template. This is a very simple customisation that only selects the TEI elements needed for producing valid TEI documents. Select this template and press the <q>Start</q> button.</p>
        <p>This will produce a configuration screen for your fresh TEI customisation:
          <figure xml:id="figure4">
            <graphic url="../../../images/tutorials/TBED08v00/romaSettings.png"/>
            <head type="legend">ODD configuration screen in Roma.</head>
          </figure>
        </p>
        <p>Here, you can enter details about your customisation file. Let’s just personalise the metadata. Fill in: 
          <list rend="bulleted">
            <item>
                            <q>A TBE Customisation</q> in the <q>Title</q> field;</item>
            <item>
                            <q>TBEcustom</q> in the <q>Filename</q> field; and</item>
            <item>
                            <q>The TBE crew</q> in the <q>Author</q> field.</item>
          </list>
                </p>
        <p>That’s it! We have created a first TEI customisation already, or at least an abstract representation in the Roma web interface. In order to use your TEI customisation in your project, you’ll not only have to derive a schema to tell your XML parser what you consider a valid TEI document for your project, but most likely also human-readable documentation to tell your project team how they should encode the text phenomena they’ll encounter in your project.</p>
        <div xml:id="powerofODD">
          <head>The Power of ODD</head>
          <p>Remember how ODD stands for <soCalled>One Document Does it all</soCalled>? You can derive a number of different schema and documentation output formats from the single ODD file you’re editing! The <q>Download</q> button at the top right of the Roma screen lets you choose between 3 types of output:
            <list rend="bulleted">
              <item>ODD files</item>
              <item>schema files, in a number of flavours</item>
              <item>documentation files, in a number of output formats</item>
            </list>
          </p>
          <p>Since these are frequent operations when customising TEI, they are treated in separate sections below.</p>
          <div xml:id="schemaGen">
            <head>Generating a Schema</head>
            <p>Select the <q>Download</q> button at the top right in the Roma screen, and choose the schema language of your choice (the various schema language output formats are highlighted in yellow):
              <figure xml:id="figure5">
                <graphic url="../../../images/tutorials/TBED08v00/romaDownloadSchema.png"/>
                <head type="legend">Schema download formats in Roma.</head>
              </figure>
            </p>
            <p>Roma can generate schemas in following schema languages: 
              <list rend="bulleted">
                <item>RelaxNG schema: a schema in the more verbose <ref target="https://relaxng.org/spec-20011203.html">XML syntax</ref> of the RelaxNG language</item>
                <item>RelaxNG compact: a schema in the more concise <ref target="https://relaxng.org/compact-20021121.html">compact syntax</ref> of the RelaxNG language</item>
                <item>W3C schema: a schema in the <ref target="https://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/">W3C XSD schema</ref> language</item>
                <item>DTD: a schema in the <ref target="https://www.w3.org/TR/xml/#dt-doctype">DTD</ref> language</item>
                <item>ISO Schematron constraints: a stand-alone file containing all <ref target="http://schematron.com/">ISO Schematron</ref> constraints that are present in the ODD file.</item>
              </list>
            </p>
            <p>Although the schemas generated in these different schema languages are roughly equivalent, some schema languages offer more expressive power than others. The schema languages that offer most complete coverage of TEI features are RelaxNG (XML syntax) and W3C schema.</p>
            <note>We’ll not go into details about the differences between these XML schema languages here. For more information, Wikipedia is your friend: <ptr target="https://en.wikipedia.org/wiki/XML_schema"/>.</note>
            <p>When choosing one of the schema flavours, your browser will download a file named <ident type="file">TBEcustom</ident> (as we had specified earlier for our ODD in the <q>Settings</q> Roma tab). The file’s extension depends on the schema format chosen: <code>.rng</code> (Relax NG XML), <code>.rnc</code> (Relax NG compact), <code>.xsd</code> (W3C schema), <code>.dtd</code> (DTD), or <code>.isosch</code> (ISO Schematron). You can store this file and use it to validate your TEI documents.</p>
          </div>
          <div xml:id="docGen">
            <head>Generating Documentation for a Customisation</head>
            <p>Select the <q>Download</q> button at the top right in the Roma screen, and choose the documentation format of your choice (the various documentation formats are highlighted in yellow):
              <figure xml:id="figure6">
                <graphic url="../../../images/tutorials/TBED08v00/romaDownloadDocumentation.png"/>
                <head type="legend">Documentation download formats in Roma.</head>
              </figure>
            </p>
            <p>Roma can generate documentation in following formats: 
              <list rend="bulleted">
                <item>HTML: a web page containing the documentation of the TEI customisation</item>
                <item>TEI Lite: a TEI Lite file containing the documentation of the TEI customisation</item>
                <item>MS Word: a Word file containing the documentation of the TEI customisation</item>
                <item>LaTeX: a LaTeX file containing the documentation of the TEI customisation</item>
              </list>
            </p>
            <p>Make sure you save the file, and see how this produces a file named <ident type="file">TBEcustom</ident>, either in HTML, TEI XML, DOCX, or LaTeX format. This documentation can serve as your project-specific TEI Guidelines, containing formal references for all elements in the schema, as well as any prose documentation present in the ODD file.</p>
          </div>
          <div xml:id="romaODD">
            <head>Generating an ODD File</head>
            <p>We saved the best for last: without doubt, saving your customisation as an ODD file is <emph>the</emph> most important step of customising TEI with Roma. It will allow you (and others) to upload this customisation again for reuse, fine tune it further, and / or generate both schemas and documentation from this single source file again. Notice that, although all changes you make in the Roma web interface are being recorded automatically, you still have to save your customisation as an ODD file. In order to do so, all you have to do is hit the <q>Download</q> button at the top right in the Roma screen, and choose one of the ODD formats (the ODD formats are highlighted in yellow):
              <figure xml:id="figure7">
                <graphic url="../../../images/tutorials/TBED08v00/romaDownloadODD.png"/>
                <head type="legend">ODD download formats in Roma.</head>
              </figure>
            </p>
            <p>Roma offers following ODD formats:
              <list rend="bulleted">
                <item>Customization as ODD: an ODD file, referencing the various TEI components</item>
                <item>Compiled ODD: an expanded ODD file, containing full documentation and with all references to the TEI components resolved</item>
              </list>
            </p>
            <p>You’ll probably need the first option: <q>Customization as ODD</q>. This will create a file called <ident type="file">TBEcustom.odd</ident>, which is a TEI XML file you can open in any plain text or XML editor. Notice, once again, how the file name corresponds to the one specified for our customisation in the <q>Settings</q> Roma tab.</p>
            <note type="summary">Roma provides a visual interface to create TEI customisations, either from any of the customisation templates provided by the TEI Consortium, or from a previously saved ODD file on your file system. Customisations can be edited in Roma and exported as an ODD (One Document Does it all) file, from which both a TEI schema and accompanying documentation can be derived in a number of output formats. The ODD file is the core of your TEI customisation.</note>
          </div>
        </div>
        <div xml:id="minimalTEI">
          <head>What Does a Minimal TEI Customisation Tell Us?</head>
          <p>Before proceeding, let’s have a closer look at what we’ve done. As mentioned before, the <ident type="file">TBEcustom.odd</ident> file we had stored earlier, is just a TEI XML file. Let’s have a look what’s inside!</p>
          <figure xml:id="example1">
            <egXML xmlns="http://www.tei-c.org/ns/Examples">
              <TEI xmlns:rng="http://relaxng.org/ns/structure/1.0" xml:lang="en">
                <teiHeader>
                  <fileDesc>
                    <titleStmt>
                      <title>A TBE Customisation</title>
                      <author>The TBE crew</author>
                    </titleStmt>
                    <publicationStmt>
                      <publisher>TEI Consortium</publisher>
                      <availability status="free">
                        <licence target="http://creativecommons.org/licenses/by-sa/3.0/"> Distributed under a Creative
                          Commons Attribution-ShareAlike 3.0 Unported License </licence>
                        <!-- ... -->
                      </availability>
                    </publicationStmt>
                    <sourceDesc>
                      <p>Created from scratch by James Cummings, but looking at previous tei_minimal and tei_bare exemplars by SPQR and LR.</p>
                    </sourceDesc>
                  </fileDesc>
                </teiHeader>
                <text>
                  <body>
                    <head>A Minimal TEI Customization</head>
                    <p>This TEI ODD defines a TEI customization that is as minimal as possible and the schema generated from it will validate
                      a document that is minimally valid against the TEI scheme. It includes only the ten required elements:
                      <list rend="numbered">
                        <item>
                                                    <gi>teiHeader</gi> from the header module to store required metadata</item>
                        <item>
                                                    <gi>fileDesc</gi> from the header module to record information about this file</item>
                        <item>
                                                    <gi>titleStmt</gi> from the header module to record information about the title</item>
                        <item>
                                                    <gi>publicationStmt</gi> from the header module to detail how it is published</item>
                        <item>
                                                    <gi>sourceDesc</gi> from the header module to record where it is from</item>
                        <item>
                                                    <gi>p</gi> from the core module for use in the header and the body</item>
                        <item>
                                                    <gi>title</gi> from the core module for use in the titleStmt</item>
                        <item>
                                                    <gi>TEI</gi> from the textstructure module because what is a TEI file without that?</item>
                        <item>
                                                    <gi>text</gi> from the textstructure module to hold some text</item>
                        <item>
                                                    <gi>body</gi> from the textstructure module as a place to put that text</item>
                      </list>
                    </p>
                    <schemaSpec ident="TBEcustom" start="TEI" prefix="tei_" targetLang="en" docLang="en">
                      
                      <!-- required minimal header elements -->
                      <moduleRef key="header" include="teiHeader fileDesc titleStmt publicationStmt sourceDesc"/>
                      
                      <!-- required core elements (p and title for use in titleStmt) -->
                      <moduleRef key="core" include="p title"/>
                      
                      <!-- required textstructure elements (TEI, text, and body) -->
                      <moduleRef key="textstructure" include="TEI text body"/>
                      
                      <!-- required module tei instantiates lots of classes used for further expansion of this odd -->
                      <moduleRef key="tei"/>  
                    </schemaSpec>
                  </body>
                </text>
              </TEI>
            </egXML>
            <head type="legend">A minimal TEI customisation ODD (<ref target="../download/TBEcustom-1-minimal.odd">download</ref>)</head>
          </figure>         
          <p>One immediate observation is that an ODD file is indeed just a regular TEI document, with a <gi>TEI</gi> root element, containing a <gi>teiHeader</gi> element and a <gi>text</gi> element. Remember the metadata you entered in the <q>Settings</q> tab in Roma, and see how it is reflected at the proper places inside the <gi>teiHeader</gi>. However, the most interesting bits are inside the <gi>body</gi> part.</p>
          <p>Apart from regular body content, as illustrated by the <gi>p</gi> contents of our minimal TEI customisation, an ODD file contains a specific <gi>schemaSpec</gi> element. This element indicates a formal definition of a TEI schema. It has a mandatory <att>ident</att> attribute, supplying an identification code for the schema. The language of the documentation can be specified with an optional <att>docLang</att> attribute; when necessary a <att>targetLang</att> attribute can specify what language to use for element and attribute names. The <att>prefix</att> attribute specifies the prefix that will be added to the names of TEI patterns in the customisation. The <att>start</att> attribute identifies the root element(s) of the customisation: in this case, it will produce a schema that only allows the <gi>TEI</gi> element as root element for valid TEI documents.</p>
          <note>Since an ODD file is just a regular TEI file, the formal schema specification in <gi>schemaSpec</gi> can be completed with a detailed prose documentation (and in fact, the concept of an ODD file is <emph>intended</emph> to contain both formal specifications and prose documentation), using the regular TEI elements in the <gi>body</gi> part. Our current example only contains very minimalistic prose documentation; for an excellent example, see the documentation in the <ref target="https://tei-c.org/release/xml/tei/custom/odd/tei_lite.odd">TEI Lite ODD file</ref>, and compare it with the different documentation files offered at <ptr target="https://tei-c.org/guidelines/customization/Lite/"/>.</note>
          <p xml:id="minimalRequirements">The <gi>schemaSpec</gi> element is the core of any ODD file, specifying the formal definition of a TEI schema. A TEI customisation can be constructed by referring to definitions of existing TEI objects (element and attribute classes, datatypes, and macros), or—as will be covered later in this tutorial—by declaring new objects as well. In our example so far, the schema specification only contains references to four of the predefined TEI modules. Each module is being referred to in a separate <gi>moduleRef</gi> element, whose <att>key</att> attribute is pointing to the formal identifier of that module in the TEI source.</p>
          <p>When a module is selected with <gi>moduleRef</gi> in an ODD file, by default all elements and attributes of that module are incorporated in the customisation. In our example, this is the case with the <ident type="module">tei</ident> module. As we have seen, this is a special module, which doesn’t define any elements and attributes itself, but instead a lot of classes, datatypes, and macros that are being used in all other TEI modules. Three of those other modules are being referenced in our current ODD file. Yet, only a very small number of elements they define are being included in our customisation, because the <gi>moduleRef</gi> elements have an <att>include</att> attribute, where only those elements that should be included are enumerated as a white-space separated list. If you count them, our customisation only selects the 10 elements that are required for minimally valid TEI documents.</p>
          <p>Notice, how the <att>include</att> mechanism has a counterpart: it is equally possible to specify which elements <emph>not</emph> to include in a module by enumerating them in an <att>except</att> attribute. This will only exclude those elements, but will include all others. Both mechanisms offer convenient shortcuts to either include or exclude large numbers of elements. It’s important to remember that you can only use either the <att>include</att> or the <att>except</att> attribute on a <gi>moduleRef</gi> element, but not both.</p>
          <note type="summary">TEI groups its different elements and their attributes in 21 modules. When defining a TEI customisation, these modules can be referred to in an ODD file. An ODD file is just a regular TEI document with a specific element for defining a TEI schema: <gi>schemaSpec</gi>. An identification for the schema must be provided in an <att>ident</att> attribute. Inside the schema specification, modules can be referenced with a <gi>moduleRef</gi> element, naming the module in a <att>key</att> attribute. When a TEI module is included in a customisation, by default all of its elements and attributes will be included. In order to include specific elements only, the names of these elements can be enumerated in an <att>include</att> attribute. Likewise, if only some of the elements of a module should be excluded, they can be enumerated in an <att>except</att> attribute on <gi>moduleRef</gi>.</note>            
          
          <!-- [RvdB] remove?          
          <p>Let’s have a closer look at what these <gi>moduleRef</gi> elements tell us:
            <list rend="bulleted">
              <item>All TEI elements and their attributes are organised thematically in 21 higher-level modules. Compare them to the shelves holding the elements and attributes, in the library analogy developed in <ptr target="#intro"/>. If a module is selected, by default all elements and attributes of that module are incorporated in the schema. In our example, all elements of the four modules being selected (with the exception of <gi>teiCorpus</gi>, which is deleted explicitly from the <ident>core</ident> module), will be included in the customisation.</item>
              <item>A minimal TEI customisation isn't empty, but will always refer to the modules <ident>tei</ident>, <ident>header</ident>, <ident>textstructure</ident>, and <ident>core</ident>. This means that if any of these modules is not referenced from an ODD file, it will never be able to define a TEI conformant schema.</item>
            </list>
          </p>
-->          
        </div>
        <div xml:id="minimalTEIRoma">
          <head>Inspecting a Customisation in Roma</head>
          <p>As we have introduced in <ptr target="#terminology" type="crossref"/>, the TEI is a highly sophisticated library, holding model and attribute classes, macros, and datatypes. Customising TEI requires some knowledge of how they are organised. Full documentation can be found in the TEI Guidelines, but fortunately, Roma is conceived as a convenient online store for selecting the exact TEI components you need, and doing so, it shows you around in the internals of TEI as well. Let’s start editing our current customisation where we have left it by hitting the <q>Customize ODD</q> button at the top right in the Roma screen:
            <figure xml:id="figure8">
              <graphic url="../../../images/tutorials/TBED08v00/romaSettings.png"/>
              <head type="legend">Start customising an ODD file with the <q>Customize ODD</q> button.</head>
            </figure>
          </p>
          <p>This will take you to the main Roma dashboard. You can tell you’re editing the right customisation from the title at the top of the screen, which reads <q>Roma - ODD Customization (A TBE customisation)</q>.
            <figure xml:id="figure9">
              <graphic url="../../../images/tutorials/TBED08v00/romaMain.png"/>
              <head type="legend">Roma main screen.</head>
            </figure>
          </p>
          <p>Below the title, you see 4 different tabs at the top of the screen:
            <list rend="bulleted">
              <item>
                                <q>Elements</q>: an overview of all available TEI elements, allowing you to select and customise those you need</item> 
              <item>
                                <q>Attribute Classes</q>: an overview of all available TEI attribute classes, allowing you to select and customise those you need</item>
              <item>
                                <q>Model Classes</q>: an overview of all available TEI model class definitions, allowing you to select and customise those you need</item>
              <item>
                                <q>Datatypes</q>: an overview of all available TEI datatype definitions, allowing you to select and customise those you need</item>
            </list>
          </p>
          <p>Let’s check how the <gi>moduleRef</gi> elements we’ve seen in our current TEI customisation are being reflected in the Roma interface. When you select the <q>Elements</q> tab, you’ll notice that only a very small number of elements are ticked. Indeed, from the long list of available TEI elements, only 10 have been selected: <gi>body</gi>, <gi>fileDesc</gi>, <gi>p</gi>, <gi>publicationStmt</gi>, <gi>sourceDesc</gi>, <gi>TEI</gi>, <gi>teiHeader</gi>, <gi>text</gi>, <gi>title</gi>, and <gi>titleStmt</gi>. Notice, how the default ordering in Roma is alphabetical; you can also click the <q>by module</q> button at the top right of the Roma screen. This will order the elements (or attribute classes, or model classes, or datatypes) alphabetically: first per module, and next by name. This sorting <soCalled>by module</soCalled> gives you an idea of what TEI components are being defined in each of the modules. This is broader than elements: if you look at the other tabs, you’ll notice that a lot of attribute classes, model classes, and datatypes are being included automatically when a TEI module is included via <gi>moduleRef</gi> in a TEI customisation.</p>
        </div>
      </div>
        </body>
  </text>
  <!-- 
      $Date: 2020-11-16 12:33:38 +0100 (Mon, 16 Nov 2020) $
      $Id: TBED08v00.xml 460 2020-11-16 11:33:38Z ron.vandenbranden $  -->
</TEI>