<?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:local="tag:textalign.net,2015:ns" xmlns="http://relaxng.org/ns/structure/1.0">
  <include href="TAN-core.rng">
    <define name="source-content">
      <choice>
        <ref name="entity-nondigital-no-id"/>
        <ref name="entity-digital-nontan-no-id"/>
      </choice>
    </define>
    <define name="networked-files-non-core">
      <interleave>
        <zeroOrMore>
          <ref name="link-element-redivision"/>
        </zeroOrMore>
        <optional>
          <ref name="link-element-model"/>
        </optional>
        <zeroOrMore>
          <ref name="link-element-annotation"/>
        </zeroOrMore>
      </interleave>
    </define>
    <define name="declaration-non-core">
      <interleave>
        <ref name="decl-class-1"/>
        <ref name="decl-non-class-1"/>
      </interleave>
    </define>
    <define name="voc-key-non-core">
      <interleave>
        <ref name="voc-element-class-1"/>
        <ref name="voc-element-non-class-1"/>
      </interleave>
    </define>
    <define name="adjust-non-core">
      <interleave>
        <zeroOrMore>
          <ref name="element-normalization"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="adjust-repl"/>
        </zeroOrMore>
      </interleave>
    </define>
    <define name="body-group">
      <empty/>
    </define>
    <define name="body-content-non-core">
      <interleave>
        <ref name="body-content-class-1"/>
        <ref name="body-content-non-class-1"/>
      </interleave>
    </define>
  </include>
  <!-- ATTRIBUTES -->
  <define name="attr-replacement">
    <attribute name="replacement">
      <a:documentation>contains a string used to replace any occurrence of @pattern </a:documentation>
    </attribute>
  </define>
  <!-- ELEMENTS -->
  <define name="element-n-alias">
    <element name="n-alias">
      <a:documentation>specifies whether aliases for n should be applied selectively. For files that use &lt;vocabulary&gt; with @which, for extra @n vocabulary, this element improves the efficiency of validation.</a:documentation>
      <ref name="ptr-attr-div-type"/>
    </element>
  </define>
  <define name="element-normalization">
    <element name="normalization">
      <a:documentation>specifies an alteration that has been made to a source file to bring the transcription into conformity with standards or common expectations. This element is used typically for minor corrections, e.g., suppression of discretionary hyphenation. You should declare every normalizing change you have made to the source.</a:documentation>
      <a:documentation>&lt;normalization&gt; is especially helpful in reference to nondigital sources, but it may be made also for digital sources, to declare global changes that would be cumbersome, difficult, or impossible to describe via regular expressions in &lt;replace&gt;. </a:documentation>
      <a:documentation>The sequence of consecutive &lt;normalization&gt; is immaterial.</a:documentation>
      <a:documentation>See main.xml#vocabularies-normalizations for standard TAN vocabulary for normalizations. For general discussion see main.xml#normalizing_transcriptions </a:documentation>
      <ref name="entity-nondigital-no-id"/>
    </element>
  </define>
  <define name="element-replace">
    <element name="replace">
      <a:documentation>contains the equivalent of the XPath replace() function plus parameters, indicating a replacement operation that should be, or has been, applied to a digital file.</a:documentation>
      <a:documentation>Multiple &lt;replace&gt;s will be assumed to have been implemented in the given order.</a:documentation>
      <a:documentation>The conventions of this element and its children parallel the XPath function replace(). See http://www.w3.org/TR/xpath-functions-30/#func-replace</a:documentation>
      <a:documentation>The sequence of consecutive &lt;replace&gt;s is important, reflecting the order in which replacements occured. Results may differ depending upon the order of replace operations.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <interleave>
          <zeroOrMore>
            <ref name="element-comment"/>
          </zeroOrMore>
          <group>
            <ref name="attr-pattern"/>
            <ref name="attr-replacement"/>
            <optional>
              <ref name="attr-flags-for-functions"/>
            </optional>
          </group>
        </interleave>
      </choice>
    </element>
  </define>
  <define name="element-version">
    <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;.  </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="entity-nondigital-no-id"/>
    </element>
  </define>
  <define name="element-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="entity-nondigital-no-id"/>
    </element>
  </define>
  <define name="link-element-annotation">
    <element name="annotation">
      <a:documentation>identifies a class-2 file that is an annotation on (and therefore a dependent of) the current file.</a:documentation>
      <a:documentation>The sequence of consecutive &lt;annotation&gt;s is immaterial.</a:documentation>
      <ref name="entity-digital-tan-no-id"/>
    </element>
  </define>
  <define name="link-element-model">
    <element name="model">
      <a:documentation>identifies a class-1 file has been used as a model for how the current file has been segmented and labeled.</a:documentation>
      <a:documentation>A file need not follow its model exactly. Upon verbose validation, differences between the file and its model will be reported only as warnings.</a:documentation>
      <ref name="entity-digital-tan-no-id"/>
    </element>
  </define>
  <define name="link-element-redivision">
    <element name="redivision">
      <a:documentation>identifies a class-1 file that has the same work, scriptum, and version, but is segmented according to a different reference system.</a:documentation>
      <a:documentation>The normalized transcriptions of redivided texts must be identical.</a:documentation>
      <a:documentation>The sequence of consecutive &lt;redivision&gt;s is immaterial.</a:documentation>
      <ref name="entity-digital-tan-no-id"/>
    </element>
  </define>
  <!-- PATTERNS -->
  <define name="adjust-repl">
    <ref name="element-replace"/>
  </define>
  <define name="body-content-class-1">
    <empty/>
  </define>
  <define name="body-content-non-class-1">
    <empty/>
  </define>
  <define name="decl-class-1">
    <interleave>
      <ref name="element-work"/>
      <optional>
        <ref name="element-version"/>
      </optional>
      <zeroOrMore>
        <ref name="element-token-definition"/>
      </zeroOrMore>
      <optional>
        <ref name="element-n-alias"/>
      </optional>
    </interleave>
  </define>
  <define name="decl-non-class-1">
    <empty/>
  </define>
  <define name="voc-element-class-1">
    <zeroOrMore>
      <ref name="voc-element-div-type"/>
    </zeroOrMore>
  </define>
  <define name="voc-element-non-class-1">
    <empty/>
  </define>
</grammar>
