<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../../lib/p5_to_atmohtml.xsl"?>
<!--* <?xml-stylesheet type="text/xsl" href="../../lib/atmo-odd.xsl"?> *-->
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" 
  type="application/xml" 
  schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" 
  type="application/xml" 
  schematypens="http://purl.oclc.org/dsdl/schematron"?>
<!DOCTYPE TEI [
<!ENTITY acirc   "&#226;" ><!-- small a, circumflex accent -->
<!ENTITY aelig   "&#230;" ><!-- small ae diphthong (ligature) -->
<!ENTITY cap    "&#x2229;" ><!--/cap B: =intersection-->
<!ENTITY cup    "&#x222A;" ><!--/cup B: =union or logical sum-->
<!ENTITY eacute  "&#233;" ><!-- small e, acute accent -->
<!ENTITY ecirc   "&#234;" ><!-- small e, circumflex accent -->
<!ENTITY icirc   "&#238;" ><!-- small i, circumflex accent -->
<!ENTITY intersect "&cap;">
<!ENTITY ldquo  "&#x201C;" ><!--=double quotation mark, left-->
<!ENTITY mdash "&#x2014;">
<!ENTITY ocirc   "&#244;" ><!-- small o, circumflex accent -->
<!ENTITY omacr   "&#x014D;" ><!-- small o, macron -->
<!ENTITY prime  "&#x2032;" ><!--/prime =prime or minute-->
<!ENTITY Prime  "&#x2033;" ><!--=double prime or second-->
<!ENTITY ucirc   "&#251;" ><!-- small u, circumflex accent -->
<!ENTITY union "&cup;">
<!ENTITY uuml    "&#252;" ><!-- small u, dieresis or umlaut mark -->

<!ENTITY nsTEI    "http://www.tei-c.org/ns/1.0" ><!-- TEI namespace name -->
<!ENTITY nsATMO   "http://uyghur.linguistics.indiana.edu/2015/ns/0.1" ><!-- ATMO namespace name -->
<!ENTITY extreme "http://conferences.idealliance.org/extreme/html">
]>
<TEI xmlns="http://www.tei-c.org/ns/1.0"
  xmlns:atmo="http://uyghur.linguistics.indiana.edu/2015/ns/0.1" 
  xmlns:rng="http://relaxng.org/ns/structure/1.0"
  xmlns:sch="http://purl.oclc.org/dsdl/schematron"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xml:lang="en">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Augmentation of base schemas for the ATMO Project</title>
        <author xml:id="CMSMcQ">C. M. Sperberg-McQueen</author>
        <sponsor>Annotated Turki Manuscripts from the Jarring Collection Online</sponsor>
        <principal>Arienne M. Dwyer</principal>
        <principal>C. M. Sperberg-McQueen</principal>
        <funder>Henry Luce Foundation</funder>
      </titleStmt>
      <publicationStmt>
        <authority>Annotated Turki Manuscripts from the Jarring Collection Online</authority>
        <pubPlace>Lawrence, Kansas</pubPlace>
        <date>2018</date>
        <availability>
          <licence>
 
            <p><ref type="license"
            target="http://creativecommons.org/licenses/by-sa/4.0/"><graphic
            rend="border-width:0"
            url="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"
            /></ref></p>
          </licence>
        </availability>
      </publicationStmt>
      <notesStmt>
        <note type="ns">http://uyghur.linguistics.indiana.edu/2015/ns/0.1</note>
      </notesStmt>
      <sourceDesc>
        <p>Created in electronic form; no source to describe.</p>
      </sourceDesc>
    </fileDesc>
    <revisionDesc>
      <change who="#CMSMcQ" when="2018-12-26">
	Some trivial copy edits.
      </change>
      <change who="#CMSMcQ" when="2018-05-22">
	Start list of differences.
      </change>
      <change who="#CMSMcQ" when="2018-05-21">
	Quick and dirty description of process of augmenting
	our base schemas.
      </change>
    </revisionDesc>
  </teiHeader>
  <text>
    <front>
      <titlePage>
        <docTitle>
          <titlePart>Augmentation of base schemas for the ATMO Project</titlePart>
        </docTitle>

        <docAuthor>C. M. Sperberg-McQueen, Black Mesa Technologies LLC</docAuthor>
        <docDate>21 May 2018, most recently revised 22 May 2018</docDate>
        <!--* <docDate>6 June 2016, last rev. 6 May 2018</docDate> *-->
        <!--* <docDate>6 June 2016, rev. 13 October 2017</docDate> *-->
        <!--* <docDate>6 June 2016, rev. 4 November 2016</docDate> *-->
        <titlePart><idno>ATMO Technical report 2018-03</idno></titlePart>

      </titlePage>

      <div xml:id="navbar" type="navbar">
        <head>Nearby documents</head>
        <list>
          <!--* <item><xref href="online.html">Online interface to Thutmose II</xref></item>
      <item><xref href="progdoc.xml">Programmers' documentation</xref></item>
    *-->
          <item xml:id="siteroot"><ref target="./../..">Home</ref></item>
        </list>
        <divGen type="toc"/>
      </div>

    </front>
    <body>
      <p>This document provides a terse description of the process
      of generating schemas for use in the ATMO project.</p>
      
      <p>The primary imaginary reader is the individual responsible
      for future maintenance of the schemas, who is assumed to have a
      working knowledge of TEI customization, XSLT, Make, and the Bash
      shell. Readers without such working knowledge are welcome to
      examine the document, but they are likely to find it heavy
      sledding.</p>
      
      <note place="block">
        <p>In its current state, this document is incomplete even by
	its own not very demanding standards of completeness.  It may
	be regarded as a promissory note, a commitment to documenting
	for future reference the steps involved in modifying the base
	schemas and re-generating the augmented schemas used in the
	project.
	</p>
      </note>

      <div xml:id="background">
	<head>Background</head>
	<p>As described more fully in <ref
	target="atmo-schemas-PTS.xml" >ATMO Technical Report
	2018-02</ref>, the ATMO project defines and uses several
	different schemas, of several different kinds.
	<list>
	  <item>
	    <p>First, there are the <term>base schemas</term> which
	    define the document as a set of pages, or as a structure
	    of paragraphs and verse, or as a sequence of sentences (in
	    paragraphs). These base schemas, called
	    <ident>P-base</ident>, <ident>T-base</ident>, and
	    <ident>S-base</ident>, respectively, are defined in <ref
	    target="atmo-schemas-PTS.xml" >ATMO TR 2018-02</ref>.</p>
	  </item>
	  <item>
	    <p>Second, there are the <term>augmented schemas</term>
	    which augment each view with elements to record the traces
	    of the other views. The traces are written as
	    <term>Trojan-Horse</term> elements, essentially as defined
	    by <ptr target="#DeRose2004"/>: empty elements marking the
	    location of what in the other view are start- or
	    end-tags.</p>
	    <p>The three augmented schemas (<ident>PTS</ident>,
	    <ident>STP</ident>, and <ident>TPS</ident>) are constructed
	    from the base schemas by an automated process. When things
	    go right, no adjustments by hand should be needed.  Things do
	    not always go right, so this document lists the hand adjustments
	    known or thought to be needed at the time of writing.
	    </p>
	  </item>
	</list>
	</p>
      </div>
      
      <div xml:id="base-gen">
	<head>Generating the base schemas</head>
	<p>The base schemas are defined by a TEI customization
	document (an <soCalled>ODD file</soCalled>, as the TEI calls
	them; ODD = <gloss>One Document Does it all</gloss>). In
	principle any method of invoking the TEI's ODD processor can
	be used; in practice, this is not always possible. Three
	<gi>schemaSpec</gi> elements are included in the document; one
	for each base schema. And some ODD processing interfaces are
	not prepared for input with more than one <gi>schemaSpec</gi>
	element.</p>
	<p>Running the ODD processor locally does work; it requires
	that some infrastructure be installed, but given that
	infrastructure it works reasonably well.</p>
	<div xml:id="base-infrastructure">
	  <head>Necessary infrastructure</head>
	  <p>The following need to be available:
	  <list>
	    <item><p>The TEI's stylesheets
	    (<ref target="https://github.com/TEIC/Stylesheets"
	    >https://github.com/TEIC/Stylesheets</ref>).</p></item>
	    <item><p>Some version of Saxon; Saxon HE
	    (<gloss>home edition</gloss>) should suffice.
	    If Oxygen is installed, jar files for Saxon will be available
	    within the Oxygen directory.</p></item>
	    <item><p>Some version of Java; the ODD processor
	    organizes its work using Ant processes.</p></item>
	    <item><p>Optionally, the TEI Guidelines
	    (<ref target="https://github.com/TEIC/TEI"
	    >https://github.com/TEIC/TEI</ref>).  The only
	    bit actually used appears to be the file
	    <ident>p5subset.xml</ident>; if Oxygen is installed,
	    this file is present in Oxygen's library directories.</p></item>
	  </list>
	  </p>
	</div>
	<div xml:id="base-run">
	  <head>Running the ODD processor</head>
	  <p>To generate a given base schema in RelaxNG's XML syntax, the basic form of command is
	  <code><ident>$(TEISS)</ident>/teitorelaxng
	  --oxygenlib=<ident>$(OXLIB)</ident>
	  --localsource=<ident>$(P5SUB)</ident>
	  --schema=<ident>$(SCHEMASPEC-ID)</ident>
	  <ident>$(INPUT)</ident>
	  <ident>$(OUTPUT)</ident></code>,
	  where
	  <list>
	    <item><p><ident>$(TEISS)</ident> is the path to the
	    <ident>bin</ident> directory of the local installation of
	    the TEI Stylesheet package. On the author's work machine,
	    for example, this is <ident>/Users /cmsmcq /2017
	    /TEIC-Stylesheets /Stylesheets /bin</ident>. (N.B.
	    whitespace has been added here to allow line-breaking.
	    Take the blanks back out.)</p>
	    </item>
	    <item><p><ident>$(OXLIB)</ident> is the path to the
	    <ident>lib</ident> directory of the local installation of
	    Oxygen. On the author's work machine,
	    for example, this is
	    <ident>/Applications/Oxygen-17.1/oxygen/lib</ident>.</p>
	    </item>
	    
	    <item><p><ident>$(P5SUB)</ident> is the path to the local
	    copy of the file <ident>p5subset.xml</ident>. (It is
	    optional; if the <code>--localsource</code> option is not
	    specified, the process will read the file from the TEI
	    Consortium's web server. The processing will take a little
	    longer owing to network delays, and results may not be
	    consistent from day to day as the TEI server is updated.)
	    On the author's work machine, this is <ident>/Applications
	    /Oxygen-17.1 /oxygen /frameworks /tei /xml /tei /odd
	    /p5subset.xml</ident>.)</p>
	    </item>
	    
	    <item><p><ident>$(SCHEMASPEC-ID)</ident> is the ID value
	    of the <gi>schemaSpec</gi> element to be processed.
	    In TR 2018-02, this will be one of <ident>P-base</ident>,
	    <ident>T-base</ident>, or <ident>S-base</ident>.</p>
	    </item>
	    
	    <item><p><ident>$(INPUT)</ident> is the filename of
	    the ODD document: here,
	    <ident>atmo-schemas-PTS.xml</ident>.</p>
	    </item>
	    <item><p><ident>$(OUTPUT)</ident> is the filename of
	    the desired RNC document: here, <ident>$schemaSpec-id</ident>
	    + <ident>.rnc</ident>.</p>
	    </item>
	  </list>
	  </p>	  
	  <p>A concrete invocation of the process for base T might read:
	  <eg>
OXAPP=/Applications/Oxygen-17.1/oxygen
TEIFW=frameworks/tei/xml/tei/odd
/Users/cmsmcq/2017/TEIC-Stylesheets/Stylesheets/bin/teitornc \
	--oxygenlib=${OXAPP}/lib \
	--localsource=${OXAPP}/${TEIFW}/p5subset.xml \
	--schema=T-base \
	atmo-schemas-PTS.xml T-base.rnc	    
	  </eg></p>
	  <p>For the compact syntax, the form of the command is very similar, but uses a different shell script:	  
	  <code><ident>$(TEISS)</ident>/teitornc
	  --oxygenlib=<ident>$(OXLIB)</ident>
	  --localsource=<ident>$(P5SUB)</ident>
	  --schema=<ident>$schemaSpec-id</ident>
	  <ident>$input-filename</ident>
	  <ident>$output-filename</ident></code></p>
	  <p>Such long commands are tedious to type.
	  To make the process more convenient, a Makefile has been installed
	  in directory /2018/05; if the variables in the directory
	  are correctly set for the current machine, then the
	  process is simpler. 
	  To update the base schemas in the /2018/05 directory,
	  navigate to that directory,
	  edit the ODD file as needed, and then type <code>make all</code>
	  or just <code>make</code>.  All three base schemas will
	  be generated.</p>
	  <p>To propagate the newly generated schemas to the /lib
	  directory, it is necessary to copy them.  Again, a Makefile
	  has been provided.  Navigate to the /lib directory and
	  type <code>make base</code>.</p>
	</div>
	<div xml:id="base-nogo">
	  <head>Blind alleys</head>
	  <p>Two other ways of running the TEI's ODD processor should
	  be mentioned, if only to explain why they are not described above.</p>
	  <p>The TEI maintains a Web interface for ODD processing at
	  <ref
	      target="http://www.tei-c.org/Roma/">http://www.tei-c.org/Roma/</ref>.
	  Using it, one can upload one's ODD document (in this case, the
	  ODD document is TR 2018-02,
	  <ident>atmo-schemas-PTS.xml</ident> in the same directory as
	  this document) and generate the schemas.
	  The Roma interface currently provides no mechanism for specifying
	  the identifier of the <gi>schemaSpec</gi> to be processed, and
	  it chokes on the ODD document in TR 2018-02.</p>
	  <p>The Oxygen XML editor from SyncRO Soft SRL ships with
	  pre-installed schemas and transformation scenarios for TEI documents,
	  including TEI ODD documents.
	  Unfortunately, the predefined transformation scenario 
	  currently provides no mechanism for specifying
	  the identifier of the <gi>schemaSpec</gi> to be processed.</p>
	</div>
      </div>
      
      <div xml:id="aug-gen">
	<head>Generating the augmented schemas</head>
	<p>The augmented schemas could in principle (and in a perfect world
	would in practice) be generated from ODD documents.  It has proven
	simpler and quicker in practice to create the augmented schemas by
	writing an XSLT stylesheet to generate them from the base schemas.</p>
	<p>The stylesheet is called <ident>augment-base-schema.xsl</ident>
	and it is located in the /lib directory.  It takes a <ident>target</ident>
	parameter to specify which augmented schema to generate:
	<ident>PTS</ident>, <ident>STP</ident>, or <ident>TPS</ident>.
	</p>
	<p>The simplest way to run it, is to adjust the variables in
	the Makefile in the /lib directory and then type <code>make
	base; make all</code>.</p>
      </div>
      
      <div xml:id="hand-edits">
	<head>Adjustments</head>
	<p>At this writing, the version of STP in /lib differs from the
	automatically generated form in the following ways.  Where
	possible, the ODD should be modified to make these changes
	in the base schemas, instead of requiring hand changes.</p>
	<list>
	  <item>
	    <p>The ODD file sometimes omits the necessary namespace
	    prefix when generating Schematron rules for ATMO elements.
	    The rule for <gi>atmo:s-wrap</gi> comes out (after elision
	    of some unnecessary namespace declarations) as
	    <eg><![CDATA[
         <pattern xmlns="http://purl.oclc.org/dsdl/schematron"
                  id="S-base-s-wrap-no-atmo-s-wrap-in-header-constraint-report-9">
            <rule context=":s-wrap">
               <sch:report xmlns="http://www.tei-c.org/ns/1.0"
                           test="ancestor::tei:teiHeader">
                    Do not use atmo:s-wrap within the TEI Header.
                  </sch:report>
            </rule>
         </pattern>
	 ]]></eg>
	    </p>
	    <p>A search in the RNG file for <q><code>=":</code></q> will
	    find all the cases.  At the moment, <gi>atmo:s-wrap</gi>
	    appears to be the only sufferer; <gi>atmo:seg</gi> et al.
	    do not exhibit the problem.</p>
	    <p>So far I have not figured out where the problem is
	    or how to work around it, so a hand fix is the only option.</p>
	  </item>
	</list>
      </div>


    </body>
    <back>
      <div xml:id="references">
        <head>References</head>
        <listBibl>
 
          <bibl xml:id="DeRose2004" n="DeRose 2004">
            <author>DeRose, Steven</author>.
            <date>2004</date>.
            <title level="a">Markup overlap: 
              A review and a Horse</title>.
            Paper given at Extreme Markup Languages 2004, 
            Montr&eacute;al, sponsored by IDEAlliance. <!--*
            Available on the Web at 
            <ref target="http://www.mulberrytech.com/Extreme
            /Proceedings/html/2004/DeRose01/EML2004DeRose01.html"
            >http://www.mulberrytech.com/Extreme/Proceedings/html
            /2004/DeRose01/EML2004DeRose01.html"</ref>.
            *-->
            On the Web at <ref
            target="&extreme;/2004/DeRose01/EML2004DeRose01.html"
            >http://conferences.idealliance.org / extreme / html / 2004
            / DeRose01 / EML2004DeRose01.html</ref>.
          </bibl>
 
        </listBibl>
      </div>
    </back>
  </text>
</TEI>
