<?xml version=“1.0” encoding=“UTF-8”?> <grammar ns=“www.metanorma.org/ns/iso” xmlns=“relaxng.org/ns/structure/1.0” datatypeLibrary=“www.w3.org/2001/XMLSchema-datatypes”>

<!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
<include href="isodoc.rng">
  <start>
    <ref name="iso-standard"/>
  </start>
  <define name="organization">
    <element name="organization">
      <oneOrMore>
        <ref name="orgname"/>
      </oneOrMore>
      <optional>
        <ref name="abbreviation"/>
      </optional>
      <optional>
        <ref name="uri"/>
      </optional>
      <zeroOrMore>
        <ref name="org-identifier"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="contact"/>
      </zeroOrMore>
      <optional>
        <ref name="technical-committee"/>
      </optional>
      <optional>
        <ref name="subcommittee"/>
      </optional>
      <optional>
        <ref name="workgroup"/>
      </optional>
      <optional>
        <ref name="secretariat"/>
      </optional>
    </element>
  </define>
  <define name="BibDataExtensionType">
    <ref name="doctype"/>
    <optional>
      <ref name="docsubtype"/>
    </optional>
    <optional>
      <ref name="horizontal"/>
    </optional>
    <ref name="editorialgroup"/>
    <zeroOrMore>
      <ref name="ics"/>
    </zeroOrMore>
    <ref name="structuredidentifier"/>
    <optional>
      <ref name="stagename"/>
    </optional>
  </define>
  <define name="bdate">
    <element name="date">
      <attribute name="type">
        <choice>
          <ref name="BibliographicDateType"/>
          <text/>
        </choice>
      </attribute>
      <choice>
        <group>
          <element name="from">
            <ref name="ISO8601Date"/>
          </element>
          <optional>
            <element name="to">
              <ref name="ISO8601Date"/>
            </element>
          </optional>
        </group>
        <element name="on">
          <choice>
            <ref name="ISO8601Date"/>
            <value>--</value>
            <value>–</value>
          </choice>
        </element>
      </choice>
    </element>
  </define>
  <define name="sections">
    <element name="sections">
      <zeroOrMore>
        <choice>
          <ref name="note"/>
          <ref name="admonition"/>
        </choice>
      </zeroOrMore>
      <ref name="clause"/>
      <optional>
        <choice>
          <ref name="term-clause"/>
          <ref name="terms"/>
        </choice>
      </optional>
      <optional>
        <ref name="definitions"/>
      </optional>
      <oneOrMore>
        <choice>
          <ref name="clause"/>
          <ref name="term-clause"/>
          <ref name="terms"/>
        </choice>
      </oneOrMore>
    </element>
  </define>
  <define name="Clause-Section">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="language"/>
    </optional>
    <optional>
      <attribute name="script"/>
    </optional>
    <optional>
      <attribute name="inline-header">
        <data type="boolean"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="obligation">
        <choice>
          <value>normative</value>
          <value>informative</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="type"/>
    </optional>
    <optional>
      <ref name="section-title"/>
    </optional>
    <choice>
      <choice>
        <group>
          <oneOrMore>
            <ref name="BasicBlock"/>
          </oneOrMore>
          <zeroOrMore>
            <ref name="note"/>
          </zeroOrMore>
        </group>
        <ref name="amend"/>
      </choice>
      <oneOrMore>
        <ref name="clause-subsection"/>
      </oneOrMore>
    </choice>
  </define>
  <define name="term">
    <element name="term">
      <optional>
        <attribute name="id">
          <data type="ID"/>
        </attribute>
      </optional>
      <ref name="preferred"/>
      <zeroOrMore>
        <ref name="admitted"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="deprecates"/>
      </zeroOrMore>
      <optional>
        <ref name="termdomain"/>
      </optional>
      <ref name="termdefinition"/>
      <zeroOrMore>
        <ref name="termnote"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="termexample"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="termsource"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="term"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="annex">
    <element name="annex">
      <optional>
        <attribute name="id">
          <data type="ID"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="language"/>
      </optional>
      <optional>
        <attribute name="script"/>
      </optional>
      <optional>
        <attribute name="inline-header">
          <data type="boolean"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="obligation">
          <choice>
            <value>normative</value>
            <value>informative</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <ref name="section-title"/>
      </optional>
      <zeroOrMore>
        <!--
          allow hanging paragraps in annexes: they introduce lists
          ( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | figure | quote | sourcecode | review | example )*,
        -->
        <ref name="BasicBlock"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="note"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="clause-hanging-paragraph-with-footnote"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="annex-appendix"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="AdmonitionType">
    <choice>
      <value>danger</value>
      <value>caution</value>
      <value>warning</value>
      <value>important</value>
      <value>safety precautions</value>
    </choice>
  </define>
  <define name="preface">
    <element name="preface">
      <optional>
        <ref name="abstract"/>
      </optional>
      <ref name="foreword"/>
      <optional>
        <ref name="introduction"/>
      </optional>
    </element>
  </define>
  <define name="DocumentType">
    <choice>
      <value>international-standard</value>
      <value>technical-specification</value>
      <value>technical-report</value>
      <value>publicly-available-specification</value>
      <value>international-workshop-agreement</value>
      <value>guide</value>
      <value>amendment</value>
      <value>technical-corrigendum</value>
      <value>directive</value>
    </choice>
  </define>
  <define name="DocumentSubtype">
    <choice>
      <value>specification</value>
      <value>method-of-test</value>
      <value>vocabulary</value>
      <value>code-of-practice</value>
    </choice>
  </define>
  <define name="structuredidentifier">
    <element name="structuredidentifier">
      <optional>
        <attribute name="type"/>
      </optional>
      <group>
        <ref name="documentnumber"/>
        <optional>
          <ref name="tc-documentnumber"/>
        </optional>
      </group>
    </element>
  </define>
  <define name="foreword">
    <element name="foreword">
      <ref name="Basic-Section"/>
    </element>
  </define>
  <define name="introduction">
    <element name="introduction">
      <ref name="Content-Section"/>
    </element>
  </define>
  <define name="editorialgroup">
    <element name="editorialgroup">
      <oneOrMore>
        <ref name="technical-committee"/>
      </oneOrMore>
      <zeroOrMore>
        <ref name="subcommittee"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="workgroup"/>
      </zeroOrMore>
      <optional>
        <ref name="secretariat"/>
      </optional>
    </element>
  </define>
  <define name="Content-Section">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="language"/>
    </optional>
    <optional>
      <attribute name="script"/>
    </optional>
    <optional>
      <attribute name="inline-header">
        <data type="boolean"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="obligation">
        <choice>
          <value>normative</value>
          <value>informative</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="number"/>
    </optional>
    <optional>
      <attribute name="type"/>
    </optional>
    <optional>
      <ref name="section-title"/>
    </optional>
    <choice>
      <group>
        <zeroOrMore>
          <ref name="BasicBlock"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="note"/>
        </zeroOrMore>
      </group>
      <oneOrMore>
        <ref name="content-subsection"/>
      </oneOrMore>
    </choice>
  </define>
</include>
<!-- end overrides -->
<!--
  We display the Normative References between scope and terms; but to keep the
  grammar simple, we keep the references together
-->
<define name="iso-standard">
  <element name="iso-standard">
    <attribute name="version"/>
    <attribute name="type">
      <choice>
        <value>semantic</value>
        <value>presentation</value>
      </choice>
    </attribute>
    <ref name="bibdata"/>
    <zeroOrMore>
      <ref name="termdocsource"/>
    </zeroOrMore>
    <optional>
      <ref name="misccontainer"/>
    </optional>
    <optional>
      <ref name="boilerplate"/>
    </optional>
    <ref name="preface"/>
    <oneOrMore>
      <ref name="sections"/>
    </oneOrMore>
    <zeroOrMore>
      <ref name="annex"/>
    </zeroOrMore>
    <ref name="bibliography"/>
    <zeroOrMore>
      <ref name="indexsect"/>
    </zeroOrMore>
  </element>
</define>
<define name="horizontal">
  <element name="horizontal">
    <data type="boolean"/>
  </element>
</define>
<define name="documentnumber">
  <element name="project-number">
    <optional>
      <attribute name="part">
        <data type="int"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="subpart">
        <data type="int"/>
      </attribute>
    </optional>
    <text/>
  </element>
</define>
<define name="tc-documentnumber">
  <element name="tc-document-number">
    <data type="int"/>
  </element>
</define>
<define name="subcommittee">
  <element name="subcommittee">
    <ref name="IsoWorkgroup"/>
  </element>
</define>
<define name="workgroup">
  <element name="workgroup">
    <ref name="IsoWorkgroup"/>
  </element>
</define>
<define name="secretariat">
  <element name="secretariat">
    <text/>
  </element>
</define>
<define name="clause-hanging-paragraph-with-footnote">
  <element name="clause">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="language"/>
    </optional>
    <optional>
      <attribute name="script"/>
    </optional>
    <optional>
      <attribute name="inline-header">
        <data type="boolean"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="obligation">
        <choice>
          <value>normative</value>
          <value>informative</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <ref name="section-title"/>
    </optional>
    <zeroOrMore>
      <!-- allow hanging paragraphs in annexes: they introduce lists -->
      <ref name="BasicBlock"/>
    </zeroOrMore>
    <zeroOrMore>
      <ref name="note"/>
    </zeroOrMore>
    <zeroOrMore>
      <ref name="clause-hanging-paragraph-with-footnote"/>
    </zeroOrMore>
  </element>
</define>
<define name="annex-appendix">
  <element name="appendix">
    <ref name="Clause-Section"/>
  </element>
</define>
<define name="stagename">
  <element name="stagename">
    <text/>
  </element>
</define>

</grammar>