<?xml version="1.0" encoding="UTF-8"?>
<!--
  /=====================================================================\ 
  |  LaTeXML-structure.rnc                                              |
  | RelaxNG model for LaTeXML generated documents                       |
  |=====================================================================|
  | Part of LaTeXML:                                                    |
  |  Public domain software, produced as part of work done by the       |
  |  United States Government & not subject to copyright in the US.     |
  |=====================================================================|
  | Bruce Miller <bruce.miller@nist.gov>                        #_#     |
  | http://dlmf.nist.gov/LaTeXML/                              (o o)    |
  \=========================================================ooo==U==ooo=/
-->
<grammar ns="http://dlmf.nist.gov/LaTeXML" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
  <!-- ====================================================================== -->
  <define name="document">
    <element name="document">
      <a:documentation>The document root.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="FrontMatter.class"/>
          <ref name="SectionalFrontMatter.class"/>
          <ref name="Meta.class"/>
          <ref name="titlepage"/>
        </choice>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="document.body.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="BackMatter.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="document.body.class">
    <a:documentation>The content allowable as the main body of the document.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="paragraph"/>
      <ref name="subsection"/>
      <ref name="section"/>
      <ref name="chapter"/>
      <ref name="part"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="part">
    <element name="part">
      <a:documentation>A part within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="part.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="part.body.class">
    <a:documentation>The content allowable as the main body of a part.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="chapter"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="chapter">
    <element name="chapter">
      <a:documentation>A Chapter within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="chapter.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="chapter.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
      <ref name="paragraph"/>
      <ref name="subsubsection"/>
      <ref name="subsection"/>
      <ref name="section"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="section">
    <element name="section">
      <a:documentation>A Section within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="section.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="section.body.class">
    <a:documentation>The content allowable as the main body of a section.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
      <ref name="paragraph"/>
      <ref name="subsubsection"/>
      <ref name="subsection"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="appendix">
    <element name="appendix">
      <a:documentation>An Appendix within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="appendix.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="appendix.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
      <ref name="paragraph"/>
      <ref name="subsubsection"/>
      <ref name="subsection"/>
      <ref name="section"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="subsection">
    <element name="subsection">
      <a:documentation>A Subsection within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsection.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subsection.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
      <ref name="paragraph"/>
      <ref name="subsubsection"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="subsubsection">
    <element name="subsubsection">
      <a:documentation>A Subsubsection within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsubsection.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subsubsection.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
      <ref name="paragraph"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="paragraph">
    <element name="paragraph">
      <a:documentation>A Paragraph within a document. This corresponds to a `formal' marked, possibly labelled
LaTeX Paragraph,  in distinction from an unlabelled logical paragraph.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="paragraph.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="paragraph.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="subparagraph"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="subparagraph">
    <element name="subparagraph">
      <a:documentation>A Subparagraph within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subparagraph.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subparagraph.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <ref name="Para.model"/>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="bibliography">
    <element name="bibliography">
      <a:documentation>A Bibliography within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <optional>
        <attribute name="files">
          <a:documentation>the list of bib files used to create the bibliograph.</a:documentation>
        </attribute>
      </optional>
      <zeroOrMore>
        <ref name="FrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="bibliography.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="bibliography.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="biblist"/>
    </choice>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="index">
    <element name="index">
      <a:documentation>An Index within a document.</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <ref name="SectionalFrontMatter.class"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="index.body.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="index.body.class">
    <a:documentation>The content allowable as the main body of a chapter.</a:documentation>
    <choice>
      <ref name="Para.model"/>
      <ref name="indexlist"/>
    </choice>
  </define>
  <define name="indexlist">
    <element name="indexlist">
      <a:documentation>A heirarchical index generated. Typically generated during postprocessing
from the collection of \elementref{indexmark} in the document
(or document collection).</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="ID.attributes"/>
      <zeroOrMore>
        <ref name="indexentry"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="indexentry">
    <element name="indexentry">
      <a:documentation>An entry in an \elementref{indexlist} consisting of a phrase, references to
points in the document where the phrase was found, and possibly
a nested \elementref{indexlist} represented index levels below this one.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="ID.attributes"/>
      <ref name="indexphrase"/>
      <optional>
        <ref name="indexrefs"/>
      </optional>
      <optional>
        <ref name="indexlist"/>
      </optional>
    </element>
  </define>
  <define name="indexrefs">
    <element name="indexrefs">
      <a:documentation>A container for the references (\elementref{ref}) to where an \elementref{indexphrase} was
encountered in the document. The model is Inline to allow
arbitrary text, in addition to the expected \elementref{ref}'s.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!-- ====================================================================== -->
  <define name="title">
    <element name="title">
      <a:documentation>The title of a document, section or similar document structure container.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="toctitle">
    <element name="toctitle">
      <a:documentation>The short form of a title, for use in tables of contents or similar.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="subtitle">
    <element name="subtitle">
      <a:documentation>A subtitle, or secondary title.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!-- NOTE: This should be aligned with Bibname. -->
  <define name="personname">
    <element name="personname">
      <a:documentation>A person's name.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="creator">
    <element name="creator">
      <a:documentation>Generalized document creator.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>indicates the role of the person in creating the docment.
Commonly useful values are specified, but is open-ended to support extension.</a:documentation>
          <choice>
            <value>author</value>
            <value>editor</value>
            <value>translator</value>
            <value>contributor</value>
            <value>translator</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <zeroOrMore>
        <choice>
          <ref name="Person.class"/>
          <ref name="Misc.class"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="Person.class">
    <a:documentation>The content allowed in authors, editors, etc.</a:documentation>
    <choice>
      <ref name="personname"/>
      <ref name="contact"/>
    </choice>
  </define>
  <define name="contact">
    <element name="contact">
      <a:documentation>Generalized contact information for a document creator.
Note that this element can be repeated to give different types 
of contact information (using \attr{role}) for the same creator.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>indicates the type of contact information contained.
Commonly useful values are specified, but is open-ended to support extension.</a:documentation>
          <choice>
            <value>affiliation</value>
            <value>address</value>
            <value>current_address</value>
            <value>email</value>
            <value>url</value>
            <value>thanks</value>
            <value>dedicatory</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="date">
    <element name="date">
      <a:documentation>Generalized document date.
Note that this element can be repeated to give the dates
of different events (using \attr{role}) for the same document.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>indicates the relevance of the date to the document.
Commonly useful values are specified, but is open-ended to support extension.</a:documentation>
          <choice>
            <value>creation</value>
            <value>conversion</value>
            <value>posted</value>
            <value>received</value>
            <value>revised</value>
            <value>accepted</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="abstract">
    <element name="abstract">
      <a:documentation>A document abstract.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Block.model"/>
    </element>
  </define>
  <define name="acknowledgements">
    <element name="acknowledgements">
      <a:documentation>Acknowledgements for the document.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="keywords">
    <element name="keywords">
      <a:documentation>Keywords for the document. The content is freeform.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="classification">
    <element name="classification">
      <a:documentation>A classification of the document.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="scheme">
          <a:documentation>indicates what classification scheme was used.</a:documentation>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!--
    ======================================================================
    Fallback
  -->
  <define name="titlepage">
    <element name="titlepage">
      <a:documentation>block of random stuff marked as a titlepage</a:documentation>
      <ref name="Sectional.attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="FrontMatter.class"/>
          <ref name="SectionalFrontMatter.class"/>
          <ref name="Block.class"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <!-- ====================================================================== -->
  <define name="Sectional.attributes">
    <a:documentation>Attributes shared by all sectional elements</a:documentation>
    <ref name="Common.attributes"/>
    <ref name="Labelled.attributes"/>
  </define>
  <define name="SectionalFrontMatter.class">
    <a:documentation>The content allowed for the front matter of each sectional unit,
and the document.</a:documentation>
    <choice>
      <ref name="title"/>
      <ref name="toctitle"/>
      <ref name="creator"/>
    </choice>
  </define>
  <define name="FrontMatter.class">
    <a:documentation>The content allowed (in addition to \patternref{SectionalFrontMatter.class})
for the front matter of a document.</a:documentation>
    <choice>
      <ref name="subtitle"/>
      <ref name="date"/>
      <ref name="abstract"/>
      <ref name="acknowledgements"/>
      <ref name="keywords"/>
      <ref name="classification"/>
    </choice>
  </define>
  <define name="BackMatter.class">
    <a:documentation>The content allowed a the end of a document.
Note that this includes random trailing Block and Para material,
to support articles with figures and similar data appearing `at end'.</a:documentation>
    <choice>
      <ref name="bibliography"/>
      <ref name="appendix"/>
      <ref name="index"/>
      <ref name="acknowledgements"/>
      <ref name="Para.class"/>
      <ref name="Meta.class"/>
    </choice>
  </define>
</grammar>
