Type-list.odd

From TEIWiki
Revision as of 07:14, 18 August 2010 by Syd (talk | contribs) (ODD for modifying attr that was gained ala a class)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This ODD demonstrates how to replace an attribute that a TEI element inherits from a class with a locally defined one, e.g., to add a controlled vocabulary. In this case, the type= attribute of <div> is modified.

<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:lang="en"
     xmlns:sch="http://purl.oclc.org/dsdl/schematron"
     xmlns:rng="http://relaxng.org/ns/structure/1.0"
     xmlns="http://www.tei-c.org/ns/1.0" >
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Sample ODD for Constraining <att>type</att> of <gi>div</gi></title>
        <author xml:id="SB"><name type="person">Syd Bauman</name></author>
      </titleStmt>
      <publicationStmt>
        <p>Intended for publication as an example TEI P5 customization
        on TEI Wiki</p>
        <p>© 2010 Syd Bauman and Brown University Women Writer's
        Project. Available under the GFDL.</p>
      </publicationStmt>
      <sourceDesc>
        <p>Born digital, based on the WWP EMPB schema.</p>
      </sourceDesc>
    </fileDesc>
  </teiHeader>
  <text>
    <front>
      <divGen type="toc"/>
      <div type="section">
        <head>Introduction</head>
        <p>This TEI ODD file (and thus the derived schema or reference documentation you may be
          reading) is the technical specification of a toy schema that exists just to demonstrate
          how one constrains the value of an attribute that is normally inherited from a class.</p>
      </div>
    </front>
    <body>
      <p>Modifying the definition of an attribute on a given element
      when that element normally inherits that attribute from a class
      is a bit tricky. The main <soCalled>gotcha</soCalled> is that we
      intuitively expect the <att>mode</att> attribute of
      <gi>classes</gi> to be inherited from its parent
      <gi>elementSpec</gi>. But <gi>classes</gi> has its own
      <att>mode</att> attribute (rather than inheriting it from <name
      type="class">att.combinable</name>), for which the default value
      is <val>replace</val>. Thus we need to specify <tag>classes
      mode="change"</tag>.</p>
      <schemaSpec ident="div-type-list"
                  xml:lang="en"
                  prefix="dtl_"
                  start="teiCorpus TEI text body div1">
        <moduleRef key="tei"/>
        <moduleRef key="header"/>
        <moduleRef key="core"/>
        <moduleRef key="textstructure"/>

        <elementSpec ident="div" module="core" mode="change">
          <!-- First, remove <div> from att.typed. -->
          <classes mode="change">
            <!-- Note that omitting the mode=chanage, above, is a "gotcha" that causes  -->
            <!-- in this <classes> replacing the TEI-defined <classes> (even though you -->
            <!-- expect mode= to be inherited from <elementSpec>), and since there is   -->
            <!-- no <memberOf key=model.divLike>, the resulting schema has no where for -->
            <!-- <div> to go! -->
            <memberOf key="att.typed" mode="delete"/>          <!-- do the deletion -->
          </classes>
          <attList>
            <!-- add our new type= attribute: -->
            <attDef ident="type" mode="replace" usage="req">
              <datatype minOccurs="1" maxOccurs="1">
                <rng:ref name="data.enumerated"/>
              </datatype>
              <valList type="semi">
                <valItem ident="tst1">
                  <gloss>test one</gloss>
                  <desc>a boring test string</desc>
                </valItem>
                <valItem ident="tst2">
                  <gloss>test two</gloss>
                  <desc>another boring test string</desc>
                </valItem>
                <valItem ident="tst3">
                  <gloss>test three</gloss>
                  <desc>yet another boring test string</desc>
                </valItem>
              </valList>
            </attDef>
          </attList>
        </elementSpec>

      </schemaSpec>
    </body>
  </text>
</TEI>