<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="tag:textalign.net,2015:ns" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <element name="TAN-T">
      <empty/>
    </element>
  </start>
  <!-- PART ONE OF THREE: PATTERNS REPEATEDLY USED ACROSS DIFFERENT TAN FILES -->
  <!--   1A. ATOMIC PATTERNS (alphabetical) -->
  <define name="agent-ref">
    <attribute name="who">
      <a:documentation>names an &lt;agent&gt;</a:documentation>
    </attribute>
  </define>
  <define name="attr-cert">
    <attribute name="cert">
      <a:documentation>states how certain an agent is of the data governed by the parent element, expressed as a real number from 0 (no certainty) to 1 (completely certainty).</a:documentation>
      <a:documentation> This attribute is taken into account before all other attributes except @claimant. That is, @cert is to be interpreted to mean: "@claimant has @cert confidence about the following data:...."</a:documentation>
      <a:documentation>Values of @cert amplify. Any @cert will be multiplied against any other values of @cert in a given context. For example, if an &lt;l&gt; and an &lt;m&gt; in a TAN-A-lm file each have a certainty of 0.5, then the lexico-morphological combination of the two is 0.25. In a TAN-A-tok file, if an &lt;align&gt; has a certainty of 0.6 and a child &lt;tok&gt; has a certainty of 0.3, then that &lt;tok&gt;'s actual certainty is 0.18.</a:documentation>
      <a:documentation>This attribute is inheritable. See main.xml#inheritable_attributes</a:documentation>
      <ref name="cert-content"/>
    </attribute>
  </define>
  <define name="attr-cert2">
    <attribute name="cert2">
      <a:documentation>provides a second measure of certainty. The value is taken along with @cert as the range in which an editors certainty resides. </a:documentation>
      <ref name="cert-content"/>
    </attribute>
  </define>
  <define name="certainty-stamp">
    <optional>
      <ref name="cert-claim"/>
    </optional>
    <optional>
      <ref name="ed-stamp"/>
    </optional>
  </define>
  <define name="cert-claim">
    <choice>
      <ref name="attr-cert"/>
      <group>
        <ref name="attr-cert"/>
        <ref name="attr-cert2"/>
      </group>
    </choice>
  </define>
  <define name="cert-content">
    <data type="double">
      <param name="pattern">1|0|(0\.\d*[1-9])</param>
    </data>
  </define>
  <define name="div-item-ref">
    <a:documentation>String that specifies a range of divs using the div-ref pattern joined by a hyphen or a comma.</a:documentation>
    <a:documentation>String that specifies a single &lt;div&gt;</a:documentation>
    <data type="string">
      <param name="pattern">(\w+([^\w\-]\w+)*)|.*\?\?\?.*</param>
    </data>
  </define>
  <define name="div-range-ref">
    <data type="string">
      <param name="pattern">(\w+([^\w\-]\w+)*)(((\s*-\s*)|(\s*,\s+))(\w+([^\w\-]\w+)*))*|.*\?\?\?.*</param>
    </data>
  </define>
  <define name="ed-agent">
    <attribute name="ed-who">
      <a:documentation>refers to one or more &lt;agent&gt;s who have edited (added or modified) an element or its content.</a:documentation>
      <a:documentation>Along with @ed-when, this forms the Edit Stamp pattern. See main.xml#edit_stamp</a:documentation>
      <a:documentation>This attribute is inheritable. See main.xml#inheritable_attributes</a:documentation>
    </attribute>
  </define>
  <define name="ed-time">
    <attribute name="ed-when">
      <a:documentation>marks the date or time when an element or its content was edited (added or modified)</a:documentation>
      <a:documentation>The value of must always conform to an ISO date or dateTime pattern. See main.xml#date_and_datetime.</a:documentation>
      <a:documentation>Along with @ed-who, this forms the Edit Stamp pattern. See main.xml#edit_stamp</a:documentation>
      <a:documentation>This attribute is inheritable. See main.xml#inheritable_attributes</a:documentation>
      <choice>
        <data type="dateTime"/>
        <data type="date"/>
      </choice>
    </attribute>
  </define>
  <define name="element-scope">
    <attribute name="affects-element">
      <a:documentation>names one or more TAN elements that the keywords apply to.</a:documentation>
      <a:documentation>This attribute is non-cumulatively inheritable. An element will be affected only by its values of @affects-element and not those of its ancestors.</a:documentation>
    </attribute>
  </define>
  <define name="error-flag">
    <attribute name="flags">
      <a:documentation>indicates the level of error that should be flagged to any algorithm that uses the parent element . Similar to Schematron's @role, but under a different name, to avoid confusion with TAN @roles.</a:documentation>
      <data type="string">
        <param name="pattern">warning|error|info|fatal</param>
      </data>
    </attribute>
  </define>
  <define name="func-param-pattern">
    <attribute name="pattern">
      <a:documentation>specifies a regular expression pattern to be searched for or matched. TAN regular expressions include an extended syntax, most noted by the special escape character \k{}. </a:documentation>
      <a:documentation>For more see main.xml#regular_expressions and https://www.w3.org/TR/xpath-functions-30/#regex-syntax</a:documentation>
    </attribute>
  </define>
  <define name="func-param-flags">
    <attribute name="flags">
      <a:documentation>specifies flags to be applied in an XPath function that uses regular expressions.</a:documentation>
      <a:documentation>s = dot-all mode; m = multi-line mode; i = case-insensitive mode; x = remove whitespace characters from regular expression; q = no metacharacters </a:documentation>
      <a:documentation>For more see http://www.w3.org/TR/xpath-functions-30/#flags</a:documentation>
      <data type="string">
        <param name="pattern">[smixq]+</param>
      </data>
    </attribute>
  </define>
  <define name="group-ref">
    <attribute name="group">
      <a:documentation>identifies one or more &lt;group-type&gt;s under which the parent element, and its children, should be grouped.</a:documentation>
      <a:documentation>This attribute is cumulatively inheritable. An &lt;item&gt; will be affected by its values of @group and those of its ancestors.</a:documentation>
    </attribute>
  </define>
  <define name="help-opt">
    <attribute name="help">
      <a:documentation>requests help on the context element. This attribute is equivalent to the help requested string, ???, but is useful in cases where the string cannot be placed (e.g., elements with no content or few attributes)</a:documentation>
      <empty/>
    </attribute>
  </define>
  <define name="href-opt">
    <attribute name="href">
      <a:documentation>points to the location of a file. In some contexts, this attribute is allowed only as a temporary measure, to invoke editing assistance by means of Schematron Quick Fixes.</a:documentation>
    </attribute>
  </define>
  <define name="inclusion-att">
    <attribute name="include">
      <a:documentation>signals that the parent element is to be replaced by all elements of the same name found in the referred &lt;inclusion&gt;.</a:documentation>
    </attribute>
  </define>
  <define name="internal-non-xml-id">
    <attribute name="id">
      <a:documentation>identifies an entity described within an element. Must be unique within a given file. Must consist only of non-spacing characters.</a:documentation>
      <data type="string">
        <param name="pattern">\S+</param>
      </data>
    </attribute>
  </define>
  <define name="internal-xml-id">
    <attribute name="xml:id">
      <a:documentation>identifies an entity described within an element. Must be unique within a given file. Must consist only of word characters.</a:documentation>
    </attribute>
  </define>
  <define name="internal-idrefs">
    <attribute name="idrefs">
      <a:documentation>contains references to one or more values of @xml:id or @id in the file </a:documentation>
    </attribute>
  </define>
  <define name="IRI-gen">
    <a:documentation>Any generic IRI identifier.</a:documentation>
    <data type="anyURI">
      <param name="pattern">[a-zA-Z][\-.+a-zA-Z0-9]+:\S+</param>
    </data>
  </define>
  <define name="item-picker">
    <a:documentation>String that specifies a single item from a sequence: digits or "last(-digit)?" Similar to seq-picker.</a:documentation>
    <data type="string">
      <param name="pattern">((last|max)|((last|max)-\d+)|(\d+))|.*\?\?\?.*</param>
    </data>
  </define>
  <define name="n">
    <attribute name="n">
      <a:documentation>names a &lt;div&gt; or &lt;group&gt;. </a:documentation>
      <a:documentation>If @n is to be given more than one value, those items must be separated by a space, a comma, or some other non-word character except the hyphen. A hyphen may be used between numbers to specify a range. This feature is useful for cases where a &lt;div&gt; straddles reference markers (e.g., a translation of Aristotle that cannot be easily tied to Bekker numbers).</a:documentation>
    </attribute>
  </define>
  <define name="TAN-ver">
    <attribute name="TAN-version">
      <a:documentation>specifies the version of TAN schemas used. </a:documentation>
      <value type="string">2018</value>
    </attribute>
  </define>
  <define name="keyword-ref">
    <attribute name="which">
      <a:documentation>used to point to a reserved keyword, either a reserved tokenization pattern or a relationship.</a:documentation>
    </attribute>
  </define>
  <define name="lang-of-content">
    <attribute name="xml:lang">
      <a:documentation>specifies a language code that names the language of the text enclosed by the parent element. Values are inherited by all descendants except for those that have an @xml:lang and their descendants.  </a:documentation>
      <a:documentation>Values should adhere to BCP (Best Common Practices) 47, http://www.rfc-editor.org/rfc/bcp/bcp47.txt. For more details see main.xml#language.</a:documentation>
      <a:documentation>Examples: 'eng' (English), 'grc' (classical Greek), 'lat' (Latin) </a:documentation>
      <data type="language"/>
    </attribute>
  </define>
  <define name="lang-outside">
    <element name="for-lang">
      <a:documentation>specifies a language that is being discussed. This element does NOT name the language of the text enclosed by the parent element, which is the province of @xml:lang.</a:documentation>
      <a:documentation>Values should adhere to BCP (Best Common Practices) 47, http://www.rfc-editor.org/rfc/bcp/bcp47.txt. For more details see main.xml#language.</a:documentation>
      <a:documentation>Examples: 'eng' (English), 'grc' (classical Greek), 'lat' (Latin). For more see main.xml#language</a:documentation>
      <data type="language"/>
    </element>
  </define>
  <define name="period-ref">
    <a:documentation>specifies whether the creation and editing of the data is still in progress. Default value is true.</a:documentation>
    <attribute name="period">
      <a:documentation>names one or more &lt;period&gt;s.</a:documentation>
    </attribute>
  </define>
  <define name="progress">
    <attribute name="in-progress">
      <a:documentation>specifies whether or not the editors of the current file have not yet finished supplying the data, intend to make important changes, or otherwise wish to reserve the right to make major changes. </a:documentation>
      <a:documentation>This attribute does not claim that the data is perfect or that it will not be changed. Rather, it signals to users, especially those who would use the file the object of a &lt;source&gt;, &lt;see-also&gt;, or &lt;inclusion&gt;, the possibility of major work that may render dependent data as wrong or invalid. </a:documentation>
      <data type="boolean"/>
    </attribute>
  </define>
  <define name="relationship">
    <attribute name="relationship">
      <a:documentation>names one or more &lt;relationship&gt;s</a:documentation>
    </attribute>
  </define>
  <define name="licensor">
    <attribute name="licensor">
      <a:documentation>specifies one or more &lt;agent&gt;s who hold the rights over the material specified by the parent element (either the data of the current file, or of the source that forms the basis for the data).</a:documentation>
      <a:documentation>Nothing should be inferred from a missing @licensor from &lt;rights-source-only&gt;. Its absence does not mean that the rightsholder is unknown or nonexistent. For more, see main.xml#license</a:documentation>
    </attribute>
  </define>
  <define name="object-datatype">
    <attribute name="object-datatype">
      <a:documentation>specifies the type of data that the object must take. This attribute is intended to specify that a particular verb governs raw units, not entities definable by the IRI + name pattern. Use this attribute if and only if the verb may not govern objects defined in &lt;definitions&gt;.</a:documentation>
      <data type="string">
        <param name="pattern">string|boolean|decimal|float|double|duration|dateTime|time|date|gYearMonth|gYear|gMonthDay|gDay|gMonth|hexBinary|base64Binary|anyURI|QName|normalizedString|token|language|NMTOKEN|NMTOKENS|Name|NCName|ID|IDREF|IDREFS|ENTITY|ENTITIES|integer|nonPositiveInteger|negativeInteger|long|int|short|byte|nonNegativeInteger|unsignedLong|unsignedInt|unsignedShort|unsignedByte|positiveInteger</param>
      </data>
    </attribute>
  </define>
  <define name="object-lexical-constraint">
    <attribute name="object-lexical-constraint">
      <a:documentation>specifies a regular expression that constrains the value of any &lt;object&gt;. </a:documentation>
      <a:documentation>Note that the regular expression will be strictly followed, e.g., "\d+" will be satisfied by "a1" (because there is at least on digit). If you wish to constrain the entire value, be sure to use ^ and $, e.g., "^\d+$". </a:documentation>
    </attribute>
  </define>
  <define name="role-ref">
    <attribute name="roles">
      <a:documentation>refers to the ID of one or more &lt;role&gt;s</a:documentation>
    </attribute>
  </define>
  <define name="seq-picker">
    <a:documentation>String that specifies a range of items in a sequence: digits or "last(-digit)?" joined by hyphens (ranges) or commas. Similar to item-picker.</a:documentation>
    <data type="string">
      <param name="pattern">((last|max|all|\*)|((last|max)-\d+)|(\d+))(\s*-\s*(((last|max))|((last|max)-\d+)|(\d+)))?(\s*[, ]\s*(((last|max))|((last|max)-\d+)|(\d+))(\s+-\s+(((last|max))|((last|max)-\d+)|(\d+)))?)*|.*\?\?\?.*</param>
    </data>
  </define>
  <define name="sources-ref">
    <empty/>
  </define>
  <define name="type">
    <attribute name="type">
      <a:documentation>indicates what type of its parent element. In the context of &lt;div&gt; it specifies a type of textual unit, defined by a &lt;div-type&gt;. In the context of &lt;group&gt; it specifies a kind of group defined by a &lt;group-type&gt;.</a:documentation>
    </attribute>
  </define>
  <define name="URI-tag">
    <a:documentation>Tag URN, mandatory pattern for the IRI name of every TAN file </a:documentation>
    <data type="anyURI">
      <param name="pattern">tag:([\-a-zA-Z0-9._%+]+@)?[\-a-zA-Z0-9.]+\.[A-Za-z]{2,4},\d{4}(-(0\d|1[0-2]))?(-([0-2]\d|3[01]))?:\S+</param>
    </data>
  </define>
  <define name="when-claim">
    <attribute name="when">
      <a:documentation>indicates a date or date and time</a:documentation>
      <choice>
        <data type="dateTime"/>
        <data type="date"/>
      </choice>
    </attribute>
  </define>
  <!--
    
      1B. NON-ATOMIC PATTERNS (alphabetical)
  -->
  <define name="action-condition">
    <choice>
      <ref name="action-simple-condition"/>
      <ref name="action-complex-condition"/>
    </choice>
  </define>
  <define name="action-simple-condition">
    <ref name="action-condition-attributes"/>
  </define>
  <define name="action-condition-attributes">
    <empty/>
  </define>
  <define name="action-complex-condition">
    <oneOrMore>
      <element name="where">
        <a:documentation>identifies a condition that must be true for the following actions to be evaluated.</a:documentation>
        <a:documentation>The condition must be true for at least one value in every attribute.</a:documentation>
        <optional>
          <ref name="ed-stamp"/>
        </optional>
        <ref name="action-condition-attributes"/>
      </element>
    </oneOrMore>
  </define>
  <define name="checksum">
    <element name="checksum">
      <a:documentation>specifies some checksum that can be used to confirm the identity of a digital file being referred to. This element contains other elements that define the type and value of the checksum. Must begin with an IRI + name pattern that defines the type of checksum being used (e.g., SHA-1).</a:documentation>
      <a:documentation>This element allows later users ensure that a copies of a file are identical. </a:documentation>
      <a:documentation>The checksum will not be generated, checked, or validated by TAN schemas. Checksum validation must be provided by other means.</a:documentation>
      <ref name="entity-nondigital-ref"/>
      <element name="value">
        <a:documentation>states the value of a &lt;checksum&gt;</a:documentation>
        <data type="string" datatypeLibrary=""/>
      </element>
    </element>
  </define>
  <define name="comment">
    <element name="comment">
      <a:documentation>discusses issues relevant to nearby data. Must credit an &lt;agent&gt;, specified by @who, and a time the comment was made, specified by @when.</a:documentation>
      <ref name="when-claim"/>
      <ref name="agent-ref"/>
      <text/>
    </element>
  </define>
  <define name="constraints-on-entity">
    <ref name="constraints-on-verb"/>
  </define>
  <define name="constraints-on-verb">
    <ref name="object-datatype"/>
    <optional>
      <ref name="object-lexical-constraint"/>
    </optional>
  </define>
  <define name="ed-stamp">
    <a:documentation>Editorial stamp: who created or edited the enclosed data and when. </a:documentation>
    <ref name="ed-agent"/>
    <ref name="ed-time"/>
  </define>
  <!--
    
       FOUR TYPES OF ENTITIES THAT CAN BE REFERENCED USING THE IRI+NAME PATTERN
  -->
  <define name="entity-digital-tan-other-ref">
    <a:documentation>Reference to an external digital entity that is a TAN file; unlike other types, the keyword-ref option much be turned on and off for specific elements (e.g., not advisable for &lt;inclusion&gt;)</a:documentation>
    <choice>
      <ref name="href-opt"/>
      <group>
        <ref name="IRI-gen-ref"/>
        <ref name="metadata-human"/>
        <zeroOrMore>
          <ref name="checksum"/>
        </zeroOrMore>
        <oneOrMore>
          <ref name="loc-src"/>
        </oneOrMore>
      </group>
    </choice>
  </define>
  <define name="entity-digital-generic-ref">
    <a:documentation>Reference to an external digital entity that is not a TAN file</a:documentation>
    <choice>
      <group>
        <oneOrMore>
          <ref name="IRI-gen-ref"/>
        </oneOrMore>
        <ref name="metadata-human"/>
        <zeroOrMore>
          <ref name="checksum"/>
        </zeroOrMore>
        <oneOrMore>
          <ref name="loc-src"/>
        </oneOrMore>
      </group>
      <ref name="keyword-ref"/>
    </choice>
  </define>
  <define name="entity-digital-tan-self-ref">
    <a:documentation>Reference to self as digital entity (i.e., TAN file)</a:documentation>
    <ref name="metadata-human"/>
    <zeroOrMore>
      <ref name="loc-self"/>
    </zeroOrMore>
  </define>
  <define name="entity-nondigital-ref">
    <a:documentation>Reference to an external non-digital entity (e.g., persons, roles, works, topics)</a:documentation>
    <choice>
      <group>
        <oneOrMore>
          <ref name="IRI-gen-ref"/>
        </oneOrMore>
        <ref name="metadata-human"/>
      </group>
      <ref name="keyword-ref"/>
    </choice>
  </define>
  <define name="entity-nondigital-with-constraints-ref">
    <a:documentation>Reference to a nondigital entity that has constraints on its use</a:documentation>
    <choice>
      <group>
        <optional>
          <ref name="constraints-on-entity"/>
        </optional>
        <oneOrMore>
          <ref name="IRI-gen-ref"/>
        </oneOrMore>
        <ref name="metadata-human"/>
      </group>
      <ref name="keyword-ref"/>
    </choice>
  </define>
  <define name="entity-tok-def">
    <a:documentation>Reference to a definition of a token</a:documentation>
    <ref name="defn-tok-def"/>
    <ref name="metadata-human"/>
  </define>
  <define name="inclusion">
    <ref name="inclusion-att"/>
    <optional>
      <ref name="help-opt"/>
    </optional>
  </define>
  <define name="IRI-gen-ref">
    <element name="IRI">
      <a:documentation>contains an International Resource Identifier that serves as a name for the a concept, person, or thing referred to by the parent element. IRIs are explained at main.xml#IRIs_and_linked_data.</a:documentation>
      <a:documentation>Any kind of IRIs are allowed: URLs, tag URNs, UUIDs, etc. For names of well-known resources, a URL identifier might be preferred (http://...), to facilitate linked data. If an entity/resource lacks a suitable URL-type name, you may use or coin any other valid IRI, such as a UUID, a tag URN, or an OID. Some concepts may be difficult to find IRIs for.</a:documentation>
      <a:documentation>Sibling &lt;IRI&gt;s are to be treated as names for the same thing, not as names of different things. Nevertheless, they are not synonymous, only poecilonymic. In the terms of Web Ontology Language (http://www.w3.org/TR/owl-ref/), sibling &lt;IRI&gt;s cannot be assumed to share the relationship owl:sameAs, because they will draw from independent vocabularies that may define similar concepts differently. </a:documentation>
      <a:documentation>An element defined with multiple &lt;IRI&gt;s is technically within the intersection, not the union, of those definitions. Nevertheless, most interpretations of TAN files will draw inferences based upon the union. That is, if item A is defined by IRI X, item B by IRIs X and Y, and item C with IRI Y, it is likely that users of the data will infer identity between items A and C. It is advisable to be cautious is assigning multiple IRIs to entities.</a:documentation>
      <a:documentation>The element is named IRI instead of URI to encourage internationalization. Alphabets other than the Latin are welcome. </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <ref name="IRI-gen"/>
    </element>
  </define>
  <define name="loc-self">
    <element name="master-location">
      <a:documentation>points to a location where a master copy of the file is to be found. Use of this element entails a commitment to updating the TAN file in those locations. Also, if @in-progress is false, a &lt;master-location&gt; must be provided.</a:documentation>
      <a:documentation>The URL may be absolute or relative to the current document. </a:documentation>
      <a:documentation>&lt;master-location&gt; does not disallow the file from being kept, published, or distributed elsewhere. It merely points to the main locations where an authoritative version of the file is to be found. </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <ref name="href-opt"/>
    </element>
  </define>
  <define name="loc-src">
    <element name="location">
      <a:documentation>declares where an electronic file was found and when. </a:documentation>
      <a:documentation>The URL may be absolute or relative to the current document. </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <attribute name="when-accessed">
        <a:documentation>specifies when an electronic file was last examined</a:documentation>
        <choice>
          <data type="date"/>
          <data type="dateTime"/>
        </choice>
      </attribute>
      <ref name="href-opt"/>
    </element>
  </define>
  <define name="metadata-desc">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <group>
      <optional>
        <ref name="lang-of-content"/>
      </optional>
      <data type="string">
        <param name="pattern">(.|\n)+</param>
      </data>
    </group>
  </define>
  <define name="metadata-human">
    <oneOrMore>
      <element name="name">
        <a:documentation>provides a human-readable name of a concept, person, or thing referred to by the parent element (or the current document, if the parent element is &lt;head&gt;)</a:documentation>
        <ref name="metadata-desc"/>
      </element>
    </oneOrMore>
    <zeroOrMore>
      <element name="desc">
        <a:documentation>provides a description of a concept, person, or thing referred to by the parent element (or the current document, if the parent element is &lt;head&gt;). &lt;desc&gt; is, in effect, a &lt;comment&gt; about that concept, person, or thing. It has two possible structures, one human-readable and the other computer-readable.</a:documentation>
        <a:documentation>Under the first, human-readable approach, &lt;desc&gt; takes merely a descriptive text about the entity, optionally with @xml:lang. If you provide descriptions in other languages, it best to make sure that each version says roughly the same thing.</a:documentation>
        <a:documentation>Under the second, computer-readable approach, &lt;desc&gt; takes an IRI + name pattern plus &lt;location&gt; and @href pointing to a &lt;TAN-c&gt; file, which provides contextual information about the concept, person, or thing. </a:documentation>
        <choice>
          <ref name="metadata-desc"/>
          <choice>
            <ref name="keyword-ref"/>
            <ref name="entity-digital-tan-other-ref"/>
          </choice>
        </choice>
      </element>
    </zeroOrMore>
  </define>
  <!-- PART TWO OF THREE: STRUCTURE COMMON TO ALL TAN FILES -->
  <define name="TAN-root">
    <attribute name="id">
      <a:documentation>contains a tag URN that permanently and uniquely names the current file, the so-called IRI Name of the current file. See main.xml#iri_name for discussion.</a:documentation>
      <a:documentation>For more on the syntax of tag URNs see main.xml#tag_urn</a:documentation>
      <ref name="URI-tag"/>
    </attribute>
    <ref name="TAN-ver"/>
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <ref name="TAN-head"/>
    <ref name="TAN-body"/>
    <optional>
      <ref name="TAN-tail"/>
    </optional>
  </define>
  <!-- HEAD -->
  <define name="TAN-head">
    <element name="head">
      <a:documentation>contains the metadata (data about the data contained by &lt;body&gt;)</a:documentation>
      <a:documentation>This element indicates at a bare minimum the name of the file, the sources, the most significant parts of the editorial history; the linguistic or scholarly conventions that have been adopted in creating the data; the license, i.e., who holds what rights to the data, and what kind of reuse is allowed; the persons, organizations, or entities that helped create the data, and the roles played by each.</a:documentation>
      <a:documentation>The structure of &lt;head&gt; is shared across TAN files, with differences between them isolated to the child &lt;definitions&gt;.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <interleave>
        <zeroOrMore>
          <ref name="comment"/>
        </zeroOrMore>
        <group>
          <ref name="head-prelude"/>
          <interleave>
            <ref name="inclusion-list"/>
            <ref name="key-list"/>
            <ref name="source-list"/>
            <ref name="see-also-list"/>
          </interleave>
          <ref name="definition-list"/>
          <ref name="alter-statement"/>
          <ref name="resp-list"/>
          <ref name="change-log"/>
        </group>
      </interleave>
    </element>
  </define>
  <define name="head-prelude">
    <ref name="head-prelude-core"/>
    <ref name="head-prelude-non-core"/>
  </define>
  <define name="head-prelude-core">
    <ref name="entity-digital-tan-self-ref"/>
    <ref name="nonsource-license"/>
  </define>
  <define name="head-prelude-non-core">
    <empty/>
  </define>
  <define name="nonsource-license">
    <element name="license">
      <a:documentation>states the license under which the data is distributed and the rights associated with it, EXCLUSIVE of any rights attached to the source.</a:documentation>
      <a:documentation>Diligently check to ensure that the license you have claimed respects the rights of your sources' rightsholders. It is recommended that you license your data under a license that is similar to or more liberal than the one under which your sources have been released.</a:documentation>
      <a:documentation>For more discussion, see main.xml#license and for a list of standard vocabulary, main.xml# keywords-rights-excluding-sources</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <ref name="entity-nondigital-ref"/>
        </interleave>
      </choice>
    </element>
    <element name="licensor">
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <ref name="agent-ref"/>
      </choice>
    </element>
  </define>
  <define name="inclusion-list">
    <zeroOrMore>
      <ref name="inclusion-item"/>
    </zeroOrMore>
  </define>
  <define name="inclusion-item">
    <element name="inclusion">
      <a:documentation>specifies a TAN file that is available for inclusion. An inclusion occurs whenever an element X points to this inclusion by means of @include. TAN-compliant validators and processors will find every X that is found in the included file (checked recursively, against any inclusions of X adopted by the inclusion) and insert them at that place in the main document.</a:documentation>
      <a:documentation>Only select elements will be included, not the entire inclusion file. Exactly which elements are included is dictated by @include.</a:documentation>
      <a:documentation>Invoking an &lt;inclusion&gt; does not require its use. </a:documentation>
      <a:documentation>For more on this, see main.xml#inclusions-and-keys</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <ref name="internal-xml-id"/>
      <interleave>
        <zeroOrMore>
          <ref name="comment"/>
        </zeroOrMore>
        <ref name="entity-digital-tan-other-ref"/>
      </interleave>
    </element>
  </define>
  <define name="key-list">
    <zeroOrMore>
      <ref name="key-item"/>
    </zeroOrMore>
  </define>
  <define name="key-item">
    <element name="key">
      <a:documentation>specifies a TAN-key file that defines concepts that may be invoked by @which.</a:documentation>
      <a:documentation>For more discussion, see main.xml#tan-key</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <ref name="entity-digital-tan-other-ref"/>
        </interleave>
      </choice>
    </element>
  </define>
  <define name="source-list">
    <ref name="source-item"/>
  </define>
  <define name="source-item">
    <element name="source">
      <a:documentation>identifies the source upon which the data in the &lt;body&gt; of the current file depends.</a:documentation>
      <a:documentation>TAN-T and TAN-A-lm allow only one &lt;source&gt;. TAN-A-tok allows exactly two. All other TAN formats require one or more. </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="source-id-opt"/>
          <interleave>
            <zeroOrMore>
              <ref name="comment"/>
            </zeroOrMore>
            <choice>
              <ref name="entity-nondigital-ref"/>
              <ref name="entity-digital-generic-ref"/>
              <ref name="entity-digital-tan-other-ref"/>
            </choice>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <define name="source-id-opt">
    <a:documentation>Parameter to indicate whether &lt;source&gt; should be allowed to take xml:id (forbidden for TAN files with only one source; mandated otherwise)</a:documentation>
    <empty/>
  </define>
  <define name="see-also-list">
    <zeroOrMore>
      <ref name="see-also-item"/>
    </zeroOrMore>
  </define>
  <define name="see-also-item">
    <element name="see-also">
      <a:documentation>identifies other documents that are related to the current file.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="relationship"/>
          <interleave>
            <zeroOrMore>
              <ref name="comment"/>
            </zeroOrMore>
            <choice>
              <ref name="entity-digital-generic-ref"/>
              <ref name="entity-digital-tan-other-ref"/>
            </choice>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <!-- definitions are treated below -->
  <define name="definition-list">
    <element name="definitions">
      <a:documentation>lists terminology and definitions assumed in encoding the data.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <interleave>
        <zeroOrMore>
          <ref name="comment"/>
        </zeroOrMore>
        <ref name="definition-core"/>
        <ref name="definition-non-core"/>
      </interleave>
    </element>
  </define>
  <define name="alter-statement">
    <a:documentation>normalizations are defined at more specific levels</a:documentation>
    <optional>
      <ref name="alter-element"/>
    </optional>
  </define>
  <define name="alter-element">
    <element name="alter">
      <a:documentation>declares alterations that have been made, or should be made, to the source(s).</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="alter-condition"/>
          <interleave>
            <zeroOrMore>
              <ref name="comment"/>
            </zeroOrMore>
            <group>
              <ref name="alter-core"/>
              <ref name="alter-non-core"/>
            </group>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <define name="alter-condition">
    <empty/>
  </define>
  <define name="alter-core">
    <empty/>
  </define>
  <define name="alter-non-core">
    <empty/>
  </define>
  <define name="resp-list">
    <oneOrMore>
      <ref name="resp-item"/>
    </oneOrMore>
  </define>
  <define name="resp-item">
    <element name="resp">
      <a:documentation>specifies a role held by one or more persons, organizations, or algorithms, perhaps during a specified time period.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="agent-ref"/>
          <ref name="role-ref"/>
          <optional>
            <ref name="period-ref"/>
          </optional>
        </group>
      </choice>
    </element>
  </define>
  <define name="change-log">
    <oneOrMore>
      <element name="change">
        <a:documentation>declares a change made to the current file. Must credit an &lt;agent&gt;, specified by @who, and a time the change was made, specified by @when.</a:documentation>
        <a:documentation>Collectively, &lt;change&gt; elements are called the changelog, the revision history of the document. </a:documentation>
        <a:documentation>The editor has discretion as to how long or detailed a &lt;change&gt; should be, or how many should be retained in a changelog. Ideally, &lt;change&gt;s documenting every published version should be retained.</a:documentation>
        <a:documentation>&lt;change&gt; elements may appear in any order, but it is good practice to put the most recent at the top.</a:documentation>
        <optional>
          <ref name="ed-stamp"/>
        </optional>
        <ref name="when-claim"/>
        <optional>
          <ref name="error-flag"/>
        </optional>
        <ref name="agent-ref"/>
        <text/>
      </element>
    </oneOrMore>
  </define>
  <!-- BODY -->
  <define name="TAN-body">
    <element name="body">
      <a:documentation>contains the data</a:documentation>
      <optional>
        <ref name="progress"/>
      </optional>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <ref name="body-attributes-non-core"/>
      <interleave>
        <ref name="body-content-core"/>
        <ref name="body-content-non-core"/>
      </interleave>
    </element>
  </define>
  <define name="body-attributes-non-core">
    <empty/>
  </define>
  <define name="body-content-core">
    <zeroOrMore>
      <ref name="comment"/>
    </zeroOrMore>
  </define>
  <define name="body-content-non-core">
    <empty/>
  </define>
  <define name="body-group">
    <element name="group">
      <a:documentation>collects items that share a common property, defined by the &lt;group-type&gt; to which it refers.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="group-attributes"/>
          <oneOrMore>
            <choice>
              <ref name="body-group"/>
              <ref name="body-item"/>
            </choice>
          </oneOrMore>
        </group>
      </choice>
    </element>
  </define>
  <define name="group-attributes">
    <optional>
      <ref name="type"/>
    </optional>
    <optional>
      <ref name="n"/>
    </optional>
  </define>
  <!-- items are defined by the master schemas -->
  <define name="body-item">
    <empty/>
  </define>
  <!-- TAIL -->
  <define name="TAN-tail">
    <element name="tail">
      <a:documentation>permits any arbitrary content. This element is suitable as a placeholder for temporary data, especially to facilitate time-consuming validation routines. </a:documentation>
      <ref name="any-content"/>
    </element>
  </define>
  <define name="any-content">
    <interleave>
      <zeroOrMore>
        <ref name="any-element"/>
      </zeroOrMore>
      <text/>
    </interleave>
  </define>
  <define name="any-element">
    <element>
      <anyName/>
      <zeroOrMore>
        <ref name="any-attribute"/>
      </zeroOrMore>
      <ref name="any-content"/>
    </element>
  </define>
  <!-- We omit @xml:id to avoid id conflicts -->
  <define name="any-attribute">
    <attribute>
      <anyName>
        <except>
          <name>xml:id</name>
        </except>
      </anyName>
    </attribute>
  </define>
  <!--
    
    PART THREE OF THREE: DEFINITIONS
  -->
  <define name="definition-core">
    <interleave>
      <oneOrMore>
        <ref name="defn-agent"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="defn-role"/>
      </oneOrMore>
      <zeroOrMore>
        <ref name="defn-period"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="defn-alias"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="defn-relationship"/>
      </zeroOrMore>
      <optional>
        <ref name="defn-ambig-numerals"/>
      </optional>
    </interleave>
  </define>
  <define name="definition-non-core">
    <empty/>
  </define>
  <!-- definitions that take take an id if that is the default for the format -->
  <define name="defn-pattern-default">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <choice>
      <ref name="inclusion"/>
      <group>
        <ref name="defn-id-ref-opt"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <ref name="entity-nondigital-ref"/>
        </interleave>
      </group>
    </choice>
  </define>
  <!-- definitions that MUST take an id -->
  <define name="defn-pattern-id">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <choice>
      <ref name="inclusion"/>
      <group>
        <ref name="internal-xml-id"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <ref name="entity-nondigital-ref"/>
        </interleave>
      </group>
    </choice>
  </define>
  <!-- definitions that MAY NOT take an id -->
  <define name="defn-pattern-no-id">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <choice>
      <ref name="inclusion"/>
      <interleave>
        <zeroOrMore>
          <ref name="comment"/>
        </zeroOrMore>
        <ref name="entity-nondigital-ref"/>
      </interleave>
    </choice>
  </define>
  <!-- definitions that are constrained (verbs) -->
  <define name="defn-pattern-constrained">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <choice>
      <ref name="inclusion"/>
      <group>
        <ref name="defn-id-ref-opt"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <ref name="entity-nondigital-with-constraints-ref"/>
        </interleave>
      </group>
    </choice>
  </define>
  <!-- definitions for languages -->
  <define name="defn-pattern-language">
    <optional>
      <ref name="ed-stamp"/>
    </optional>
    <choice>
      <ref name="inclusion"/>
      <group>
        <ref name="defn-id-ref-opt"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <group>
            <zeroOrMore>
              <ref name="lang-outside"/>
            </zeroOrMore>
            <ref name="entity-nondigital-ref"/>
          </group>
        </interleave>
      </group>
    </choice>
  </define>
  <!-- agents are persons, organizations, or algorithms -->
  <define name="defn-agent">
    <choice>
      <ref name="defn-pers"/>
      <ref name="defn-org"/>
      <ref name="defn-alg"/>
    </choice>
  </define>
  <define name="defn-alias">
    <element name="alias">
      <a:documentation>assigns a group of xml:id values to a single xml:id.</a:documentation>
      <a:documentation>This feature is useful for referring repeatedly to a group of agents, works, scripta, etc. </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <choice>
            <ref name="internal-xml-id"/>
            <ref name="internal-non-xml-id"/>
          </choice>
          <ref name="internal-idrefs"/>
        </group>
      </choice>
    </element>
  </define>
  <define name="defn-ambig-numerals">
    <element name="ambiguous-letter-numerals-are-roman">
      <a:documentation>specifies whether letters that can be interpreted both as letter numerals and as roman numerals should be interpreted as the latter.</a:documentation>
      <a:documentation>E.g., 'c' would be interpreted as 3 if false and 100 if true.</a:documentation>
      <a:documentation>If element is not present, the value is assumed to be true.</a:documentation>
      <data type="boolean"/>
    </element>
  </define>
  <define name="defn-alg">
    <element name="algorithm">
      <a:documentation>contains an IRI + name pattern identifying an algorithm.</a:documentation>
      <a:documentation>Algorithm covers any set of computational instructions. It does not include the hardware or software used to run the algorithm. For example, a set of XSLT styleshteets is an algorithm, but the engine (e.g., Saxon) or software (e.g., oXygen) is not.  </a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-div-type">
    <element name="div-type">
      <a:documentation>declares a type of textual division (e.g., title, paragraph, stanza). You may have as many &lt;div-types&gt; as you wish, and they need not all be used.</a:documentation>
      <a:documentation>For more information, see main.xml#reference_system</a:documentation>
      <a:documentation>This element takes a reserved keyword or IRI + name pattern. See main.xml#keywords-div-type for suggested values. </a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-group-type">
    <element name="group-type">
      <a:documentation>defines types of &lt;group&gt;s. See main.xml# keywords-group-type</a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-id-ref-opt">
    <a:documentation>Option to allow an @xml:id in children of &lt;definitions&gt;</a:documentation>
    <empty/>
  </define>
  <define name="defn-org">
    <element name="organization">
      <a:documentation>contains an IRI + name pattern identifying an organization, a group of persons, whether formally incorporated or not.</a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-period">
    <element name="period">
      <a:documentation>defines a period of time.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="internal-xml-id"/>
          <attribute name="from">
            <a:documentation>specifies the beginning of a period of time</a:documentation>
            <choice>
              <data type="dateTime"/>
              <data type="date"/>
            </choice>
          </attribute>
          <attribute name="to">
            <a:documentation>specifies the end of a period of time</a:documentation>
            <choice>
              <data type="dateTime"/>
              <data type="date"/>
            </choice>
          </attribute>
        </group>
      </choice>
    </element>
  </define>
  <define name="defn-pers">
    <element name="person">
      <a:documentation>contains an IRI + name pattern identifying an individual human being.</a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-relationship">
    <element name="relationship">
      <a:documentation>specifies a relationship that one document has to another.</a:documentation>
      <a:documentation>See main.xml#keywords-relationship for standardized vocabulary.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="internal-xml-id"/>
          <ref name="entity-nondigital-ref"/>
        </group>
      </choice>
    </element>
  </define>
  <define name="defn-role">
    <element name="role">
      <a:documentation>specifies a role (responsibility, task, or activity) that one or more &lt;agent&gt;s did in creating or editing the data.</a:documentation>
      <a:documentation>A role may be any activity, e.g., editor, funder, supervisor, data-processor, peer reviewer, patron, defined through the enclosed IRI + name pattern.</a:documentation>
      <ref name="defn-pattern-id"/>
    </element>
  </define>
  <define name="defn-tok-def">
    <element name="token-definition">
      <a:documentation>takes a regular expression to define a word token. This element will be used to segment a string into token and non-token components. </a:documentation>
      <a:documentation>This element takes attributes that function as the parameters for the function xsl:analyze-string (see https://www.w3.org/TR/xslt-30/#element-analyze-string).</a:documentation>
      <a:documentation>For more see main.xml#defining_tokens</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="sources-ref"/>
          <choice>
            <ref name="keyword-ref"/>
            <group>
              <ref name="func-param-pattern"/>
              <optional>
                <ref name="func-param-flags"/>
              </optional>
            </group>
          </choice>
        </group>
      </choice>
    </element>
  </define>
  <define name="defn-vers">
    <element name="version">
      <a:documentation>identifies the version of a work. Applicable to sources that contain multiple versions, e.g., original text and facing translations. Like &lt;work&gt;, &lt;version&gt; points to a conceptual entity, not a physical one.</a:documentation>
      <a:documentation>In the context of a class 1 file, the entity identified by &lt;version&gt; is assumed to be a version of the entity defined in &lt;work&gt;. In TAN-c files, however, no relationship is assumed between &lt;version&gt; and any putative work, unless explicitly stated in that file. </a:documentation>
      <a:documentation>Very few work-versions have their own URN names. It is advisable to assign a tag URN or a UUID. If you have used an IRI for &lt;work&gt; that you are entitled to modify, you may wish to add a suffix that will name the version. If you need to specify exactly where on a text-bearing object a version appears, &lt;desc&gt; or &lt;comment&gt; should be used.</a:documentation>
      <a:documentation>For more, see main.xml#conceptual_works</a:documentation>
      <ref name="defn-pattern-default"/>
    </element>
  </define>
  <define name="defn-work">
    <element name="work">
      <a:documentation>identifies a creative textual work, understood conceptually, not physically (e.g., Homer's Iliad, not a particular version or copy of it).</a:documentation>
      <a:documentation>The term "work" is only loosely defined in TAN. Any text that has enough unity to be referred to in ordinary conversation as a single entity may be identified as a work. A work may be composed of other works, be a part of other works, or even overlap with other works. E.g., the Lord's Prayer, the Gospel of Luke, the Tetravengelion, the New Testament, and the Bible are all valid works, despite the complex relationship between each of them.</a:documentation>
      <a:documentation>This element takes the IRI + name pattern. For more, see main.xml#conceptual_works</a:documentation>
      <ref name="defn-pattern-default"/>
    </element>
  </define>
</grammar>
