From TEIWiki

Jump to: navigation, 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="http://www.tei-c.org/ns/1.0" >
        <title>Sample ODD for Constraining <att>type</att> of <gi>div</gi></title>
        <author xml:id="SB"><name type="person">Syd Bauman</name></author>
        <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>
        <p>Born digital, based on the WWP EMPB schema.</p>
      <change when="2011-09-01" who="#SB">
          <item>fix typos in comments</item>
          <item>fix typo in <att>start</att>: div1 -> div</item>
          <item>improve introductory prose</item>
          <item>add <gi>desc</gi></item>
          <item>added <gi>revisionDesc</gi></item>
      <divGen type="toc"/>
      <div type="section">
        <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. In this case, the <att>type</att>
        attribute of <gi>div</gi> will be constrained to a
        semi-controlled vocabulary.
	  <specDesc key="div" atts="type"/>
      <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
      <schemaSpec ident="div-type-list"
                  start="teiCorpus TEI text body div">
        <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=change, above, is a "gotcha" that causes -->
            <!-- this <classes> to replace the TEI-defined <classes> (even though you -->
            <!-- expect mode= to be inherited from <elementSpec>), and since there is -->
            <!-- no <memberOf key=model.divLike> in this <classes>, the resulting     -->
	    <!-- schema would have no where for <div> to go!                          -->
            <memberOf key="att.typed" mode="delete"/>          <!-- do the deletion -->
            <!-- add our new type= attribute: -->
            <attDef ident="type" mode="replace" usage="req">
	      <desc>allows user to choose one of three pre-determined
	      values, or to fill in her own value, which in theory
	      should express what kind of subdivision of the front,
	      body, or back of the text this is, but in fact are just
	      useless demonstrations</desc>
              <datatype minOccurs="1" maxOccurs="1">
                <rng:ref name="data.enumerated"/>
              <valList type="semi">
                <valItem ident="tst1">
                  <gloss>test one</gloss>
                  <desc>a boring test string</desc>
                <valItem ident="tst2">
                  <gloss>test two</gloss>
                  <desc>another boring test string</desc>
                <valItem ident="tst3">
                  <gloss>test three</gloss>
                  <desc>yet another boring test string</desc>

Personal tools