<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-28" who="#RvdB">integrated examples in a single file</change>
    </revisionDesc>
  </teiHeader>
  <text xml:id="TBED08v00" type="examples">
    <body>
            <head>Module 8: Customising TEI, ODD, Roma</head>
            <div xml:id="jTEI" type="example">
        <head>jTEI: a Customisation for Journal Articles</head>
        <p>This examples provides some snippets of the jTEI customisation ODD file, which defines a minimalist TEI scheme for encoding journal articles. This customisation is being used for encoding the source files of the articles of the <ref target="https://journals.openedition.org/jtei">Journal of the Text Encoding Initiative</ref>. This <soCalled>clean</soCalled> customisation defines a trimmed-down model of TEI texts, making it easier to enforce a consistent encoding style. This way, authors and editors are offered guidance in the composition and editing of an article. Inside the <gi>schemaSpec</gi> section of this <val>tei_jtei</val> customisation, you’ll see that only a limited number of elements is included from the <ident>core</ident>, <ident>corpus</ident>, <ident>figures</ident>, <ident>header</ident>, <ident>namesdates</ident>, <ident>tagdocs</ident>, <ident>tei</ident>, <ident>textstructure</ident>, and <ident>transcr</ident> TEI modules.</p>
        <p>In this example, the definition of the <gi>figure</gi> element is made more stringent, in order to enforce a very specific structure on its contents. This is done inside an <gi>elementSpec</gi> element with a value of <val>figure</val> for the <att>ident</att> attribute; the <att>mode</att> attribute indicates that the existing element element specification should be changed. The contents for the <gi>figure</gi> element are being redefined in a <gi>content</gi> element, which is specifying a very strict <term>sequence</term> of either a single <gi>graphic</gi>, <gi>egXML</gi>, or <gi>eg</gi> element, which must be followed by one or more <gi>head</gi> elements. Notice how the <gi>elementRef</gi> elements are being used to refer to these different TEI elements, and the <gi>sequence</gi> and <gi>alternate</gi> elements are being used to specify how they are combined. With the <att>minOccurs</att> and <att>maxOccurs</att> attributes on the <gi>elementRef</gi> reference to the <gi>head</gi> element, it is stipulated that at least 1 <gi>head</gi> element must be present, without an upper bound. The <gi>attList</gi> section is used to remove the attributes <att>place</att> and <att>title</att> from <gi>figure</gi>.</p>
        <p>Likewise, the specification of the <gi>titleStmt</gi> element is re(de)fined, in that its <gi>content</gi> is reduced to a sequence of one or more <gi>title</gi> elements, followed by one or more <gi>author</gi> elements. Notice that the order is important here: there’s no <gi>alternate</gi> wrapper here, that would allow alternation of these elements. Notice, too, how this <gi>elementSpec</gi> element contains additional modifications: a <gi>constraintSpec</gi> element is used to define additional <emph>Schematron</emph> checks that can express context-dependent validation rules. In this case, a rule is defined which ensures that at least one <gi>title</gi> element must be present in <gi>titleStmt</gi>, with a value <val>main</val> for its <att>type</att> attribute. For more information on the definition of such Schematron constraints in ODD: see section <ref target="https://tei-c.org/release/doc/tei-p5-doc/en/html/TD.html#TDTAGCONS">22.5.2 Additional Constraints</ref> of the TEI Guidelines.</p>
        <figure xml:id="jTEI-example">
          <egXML xmlns="http://www.tei-c.org/ns/Examples">
            <TEI xmlns="http://www.tei-c.org/ns/1.0_TBEeg_" xmlns:sqf="http://www.schematron-quickfix.com/validator/process" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:eg="http://www.tei-c.org/ns/Examples" xmlns:egXML="http://www.tei-c.org/ns/Examples" xml:lang="en">
              <teiHeader>
                <fileDesc>
                  <titleStmt>
                    <title>jTEI input customization</title>
                    <author xml:id="RvdB">
                                            <name>Ron Van den Branden</name> <email>ron.vandenbranden@kantl.be</email>
                                        </author>
                    <author xml:id="MDH">
                                            <name>Martin Holmes</name> <email>mholmes@uvic.ca</email>
                                        </author>
                  </titleStmt>
                  <editionStmt>
                    <edition>Originally generated on <date>2014-01-30T13:29:15Z</date> using oddbyexample.xsl.
                      Progressively modified after that. </edition>
                  </editionStmt>
                  <publicationStmt>
                    <p/>
                  </publicationStmt>
                  <sourceDesc>
                    <p>Originally generated by oddbyexample.xsl, based on analyzing 6 files from
                      file:/F:/ctb/jTEI/jTEIsource/branches/working docs/tei2openedition/oddbyexample. Manually modified thereafter. </p>
                  </sourceDesc>
                </fileDesc>
                <!-- ... -->
              </teiHeader>
              <text>
                <body>
                  <!-- prose documentation -->
                </body>
                <back>
                  <!-- ... -->
                  <div>
                    <schemaSpec ident="tei_jtei" start="TEI">
                      <moduleRef key="tei"/>
                      <moduleRef key="core" include="abbr author bibl biblScope cit date desc editor email emph foreign gap graphic head hi item label lb list listBibl mentioned name note num p pubPlace publisher q quote ptr ref resp respStmt series soCalled term title"/>
                      <moduleRef key="corpus" include="particDesc"/>
                      <moduleRef key="figures" include="cell figure row table"/>
                      <moduleRef key="header" include="appInfo application availability catRef change classCode edition encodingDesc fileDesc idno keywords langUsage language licence listChange profileDesc projectDesc publicationStmt rendition revisionDesc seriesStmt sourceDesc tagsDecl teiHeader textClass titleStmt"/>
                      <moduleRef key="namesdates" include="affiliation forename listPerson person placeName orgName roleName surname"/>
                      <moduleRef key="tagdocs" include="att code eg egXML gi ident tag val"/>
                      <moduleRef key="textstructure" include="TEI back body div front text"/>
                      <moduleRef key="transcr" include="supplied"/>
                      
                      <!-- ... -->
                      
                      <elementSpec ident="titleStmt" module="header" mode="change">
                        <gloss versionDate="2005-01-14" xml:lang="en">title statement</gloss>
                        <desc versionDate="2014-03-10" xml:lang="en">groups information about the title of a
                          work and those responsible for its content. In jTEI, this must include a title and an
                          <gi>author</gi> element for each author of the paper, which in turn must include
                          <gi>name</gi>, <gi>affiliation</gi> and <gi>email</gi>.</desc>
                        <content>
                          <!-- [RvdB] sequence wrapper seems necessary to keep ODD2DTD happy -->
                          <sequence>                
                            <elementRef key="title" minOccurs="1" maxOccurs="unbounded"/>
                            <elementRef key="author" minOccurs="1" maxOccurs="unbounded"/>
                          </sequence>              
                        </content>
                        <constraintSpec ident="jtei.sch-title" scheme="schematron">
                          <constraint>
                            <sch:rule context="tei:titleStmt">
                              <sch:assert test="tei:title[@type = 'main']" sqf:fix="type.add">
                                A title of type "main" is required in <sch:name/>.
                              </sch:assert>
                              <sqf:fix id="type.add">
                                <sqf:description>
                                  <sqf:title>Add a @type='main' attribute to the first title.</sqf:title>
                                </sqf:description>
                                <sqf:add match="tei:title[not(@type='main')][1]" node-type="attribute" target="type">main</sqf:add>
                              </sqf:fix>                  
                            </sch:rule>
                          </constraint>
                        </constraintSpec>
                      </elementSpec>
                      
                      <!-- ... -->
                      
                      <elementSpec xmlns:rng="http://relaxng.org/ns/structure/1.0" ident="figure" mode="change">
                        <gloss xml:lang="en" versionDate="2015-03-03">figure</gloss>
                        <desc xml:lang="en" versionDate="2015-03-03">groups elements representing or containing graphic information
                          such as a graphic illustration, or a block of example code. Figure must contain
                          either <gi>graphic</gi>, <gi>egXML</gi> (for example XML code) or <gi>eg</gi>
                          (for non-XML code), and a mandatory <gi>head</gi> element containing the caption for the 
                          figure. Inline code examples may be provided through <gi>egXML</gi> and <gi>eg</gi>
                          without the <gi>figure</gi> wrapper.
                        </desc>
                        <content>
                          <!-- [RvdB] sequence wrapper seems necessary to keep ODD2DTD happy -->
                          <sequence>
                            <alternate>
                              <elementRef key="graphic"/>
                              <elementRef key="egXML"/>
                              <elementRef key="eg"/>
                            </alternate>
                            <elementRef key="head" minOccurs="1" maxOccurs="unbounded"/>
                          </sequence>
                        </content>
                        <attList>
                          <attDef ident="place" mode="delete"/>
                          <attDef ident="type" mode="delete"/>
                        </attList>
                        <exemplum xml:lang="en">
                          <egXML xmlns="http://www.tei-c.org/ns/Examples_TBEeg_">
                            <figure>
                              <graphic url="http://www.example.org/fig1.png" width="100px" height="750px"/>
                              <head type="legend">The View from the Bridge</head>
                              <head type="license">Used with permission</head>
                            </figure>
                          </egXML>
                        </exemplum>
                        <exemplum xml:lang="en">
                          <egXML xmlns="http://www.tei-c.org/ns/Examples_TBEeg_">
                            <figure>
                              <eg>if ((err = SSLHashSHA1.update(&amp;hashCtx, &amp;serverRandom)) != 0)
                                goto fail;
                                if ((err = SSLHashSHA1.update(&amp;hashCtx, &amp;signedParams)) != 0)
                                goto fail;
                                goto fail;
                                if ((err = SSLHashSHA1.final(&amp;hashCtx, &amp;hashOut)) != 0)
                                goto fail;
                              </eg>
                              <head type="legend">An embarrassing error for Apple</head>
                            </figure>
                          </egXML>
                        </exemplum>
                        <exemplum xml:lang="en">
                          <egXML xmlns="http://www.tei-c.org/ns/Examples_TBEeg_">
                            <figure>
                              &lt;egXML xmlns="http://www.tei-c.org/ns/Examples"&gt;
                              &lt;list rend="bulleted"&gt;
                              &lt;item&gt;Life&lt;/item&gt;
                              &lt;item&gt;The Universe&lt;/item&gt;
                              &lt;item&gt;Everything&lt;/item&gt;
                              &lt;/list&gt;
                              &lt;/egXML&gt;
                              <head type="legend">A book title rendered as a list</head>
                            </figure>
                          </egXML>
                        </exemplum>
                      </elementSpec>
                      
                      <!-- ... -->
                      
                    </schemaSpec>
                  </div>
                </back>
              </text>
            </TEI>
          </egXML>
          <head type="legend">A snippet of the jTEI customisation ODD file (<ref type="bibl" target="#jtei2014">Van den Branden and Holmes, 2014</ref>). TEI XML source available from <ptr target="https://tei-c.org/release/xml/tei/custom/odd/tei_jtei.odd"/>.</head>
        </figure>
      </div>
            <div xml:id="numbereddivs" type="example">
        <head>Abolishing Numbered Text Divisions</head>
        <p>Following ODD file defines a minimal TEI schema (containing the <ident type="module">core</ident>, <ident type="module">tei</ident>, <ident type="module">header</ident>, and <ident type="module">textstructure</ident> modules). Besides that, it does away with numbered text divisions (<gi>div1</gi>, ..., <gi>div7</gi>) by specifying the value <val>delete</val> for the <att>mode</att> attribute on their respective <gi>elementSpec</gi> declarations.</p>
        <p>Notice that strictly speaking, only deletion of <gi>div1</gi> is necessary, as all further numbered subdivisions should nest according to the TEI scheme. By definition, if the topmost level is deleted, all further subdivisions are practically excluded from the document model. Although they are still declared, they can’t be used in documents according to this schema. Additionally, notice how this list of separate <gi>elementSpec</gi> instructions could be expressed more concisely as:
          <egXML xmlns="http://www.tei-c.org/ns/Examples">
            <moduleRef key="textstructure" except="div1 div2 div3 div4 div5 div6 div7"/>
          </egXML>
        </p>
        
        <figure xml:id="numbereddivs-example">
          <egXML xmlns="http://www.tei-c.org/ns/Examples">
            <TEI xmlns="http://www.tei-c.org/ns/1.0_TBEeg_" xml:lang="en">
              <teiHeader>
                <fileDesc>
                  <titleStmt>
                    <title>numbered divisions</title>
                    <author>The TBE crew</author>
                  </titleStmt>
                  <publicationStmt>
                    <p>for use by whoever wants it</p>
                  </publicationStmt>
                  <sourceDesc>
                    <p>no source, born digital</p>
                  </sourceDesc>
                </fileDesc>
              </teiHeader>
              <text>
                <front>
                  <divGen type="toc"/>
                </front>
                <body>
                  <p>This customisation only selects the minimal TEI modules, and deletes all numbered subdivisions.</p>
                  <schemaSpec ident="numDiv" xml:lang="en">
                    <moduleRef key="core"/>
                    <moduleRef key="tei"/>
                    <moduleRef key="header"/>
                    <moduleRef key="textstructure"/>
                    <elementSpec module="textstructure" ident="div1" mode="delete"/>
                    <elementSpec module="textstructure" ident="div2" mode="delete"/>
                    <elementSpec module="textstructure" ident="div3" mode="delete"/>
                    <elementSpec module="textstructure" ident="div4" mode="delete"/>
                    <elementSpec module="textstructure" ident="div5" mode="delete"/>
                    <elementSpec module="textstructure" ident="div6" mode="delete"/>
                    <elementSpec module="textstructure" ident="div7" mode="delete"/>
                  </schemaSpec>
                </body>
              </text>
            </TEI>
          </egXML>
          <head type="legend">TBE-crafted example encoding, no material source.</head>
        </figure>
      </div>
        </body>
    <back>
      <div type="bibliography">
        <listBibl>
          <bibl xml:id="jtei2014">
                        <author>Van den Branden, Ron</author> and <author>Martin Holmes</author>. <date>2014</date>. <title level="u">Journal of the Text-Encoding Initiative Article Schema. Schema and guidelines for encoding an article for the journal.</title> <ptr target="https://tei-c.org/guidelines/customization/jtei/"/>.</bibl>
        </listBibl>
      </div>
    </back>
  </text>
  <!-- 
      $Date: 2020-07-08 02:33:20 +0200 (Wed, 08 Jul 2020) $
      $Id: TBED08v00.xml 425 2020-07-08 00:33:20Z ron.vandenbranden $  -->
</TEI>