<?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="declaration-items">
      <interleave>
        <ref name="decl-class-1"/>
        <ref name="decl-non-class-1"/>
      </interleave>
    </define>
    <define name="body-group">
      <empty/>
    </define>
  </include>
  <define name="decl-class-1">
    <a:documentation>Class 1 files must declare a single work, perhaps one version, one or more divisions, one or more recommended tokenizations, perhaps one filter, and perhaps one </a:documentation>
    <interleave>
      <ref name="decl-work"/>
      <optional>
        <ref name="decl-vers"/>
      </optional>
      <oneOrMore>
        <ref name="decl-div"/>
      </oneOrMore>
      <zeroOrMore>
        <ref name="decl-tok-def"/>
      </zeroOrMore>
      <optional>
        <ref name="decl-filt"/>
      </optional>
    </interleave>
  </define>
  <define name="decl-non-class-1">
    <a:documentation>Reserved for declarations specific to individual types of class 1 files</a:documentation>
    <empty/>
  </define>
  <define name="decl-div">
    <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>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="internal-id"/>
          <interleave>
            <zeroOrMore>
              <ref name="comment"/>
            </zeroOrMore>
            <ref name="entity-nondigital-ref"/>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <define name="decl-filt">
    <element name="filter">
      <a:documentation>declares alterations that have been made to the source.</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <interleave>
        <zeroOrMore>
          <ref name="comment"/>
        </zeroOrMore>
        <ref name="decl-filter-content"/>
      </interleave>
    </element>
  </define>
  <define name="decl-filter-content">
    <interleave>
      <zeroOrMore>
        <ref name="decl-filt-norm"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="decl-filt-repl"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="decl-filt-tlit"/>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="decl-filt-norm">
    <element name="normalization">
      <a:documentation>specifies an alteration 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 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 in &lt;replace&gt;. </a:documentation>
      <a:documentation>See main.xml#keywords-normalization for suggested IRI + name values for normalizations. For general discussion see main.xml#normalizing_transcriptions </a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <group>
          <ref name="decl-id-ref-opt"/>
          <interleave>
            <zeroOrMore>
              <ref name="comment"/>
            </zeroOrMore>
            <ref name="entity-nondigital-ref"/>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <define name="decl-filt-repl">
    <a:documentation>Replacements that have been made to an XML source file. </a:documentation>
    <ref name="func-replace"/>
  </define>
  <define name="func-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 document order.</a:documentation>
      <a:documentation>The conventions of this element and its children accord with the definition of the function and its parameters provided at http://www.w3.org/TR/xpath-functions-30/#func-replace</a:documentation>
      <optional>
        <ref name="ed-stamp"/>
      </optional>
      <choice>
        <ref name="inclusion"/>
        <interleave>
          <zeroOrMore>
            <ref name="comment"/>
          </zeroOrMore>
          <group>
            <ref name="func-param-pattern"/>
            <attribute name="replacement">
              <a:documentation>contains a string used to replace any occurrence of &lt;pattern&gt; </a:documentation>
            </attribute>
            <optional>
              <ref name="func-param-flags"/>
            </optional>
          </group>
        </interleave>
      </choice>
    </element>
  </define>
  <define name="decl-filt-tlit">
    <element name="transliteration">
      <a:documentation>indicates a transliteration scheme that has been applied to a source to convert it from one writing system to another. This element may be useful if it easier to work with a source in the Latin alphabet (for example) rather than a native one. </a:documentation>
      <a:documentation>The scope of this element may be specified through optional &lt;for-lang&gt;s.</a:documentation>
      <a:documentation>This may be useful for texts easier to handle in a Latin alphabet rather than a native one.  </a:documentation>
      <ref name="decl-pattern-language"/>
    </element>
  </define>
</grammar>
