<?xml version="1.0" encoding="UTF-8"?>
<!--
  /=====================================================================\ 
  |  LaTeXML-bib.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">
  <!-- Would be nice to use somebody elses already-developed DTD... -->
  <!--
    Some notes:
    There're two classes of things here:
    bibentry : which would be the translation of a .bib file
    bibitem  : which would be the formatted items in a latex bibliography environment.
    	   This latter has typically lost much information during formatting.
  -->
  <define name="biblist">
    <element name="biblist">
      <a:documentation>A list of bibliographic \elementref{bibentry} or \elementref{bibitem}.</a:documentation>
      <ref name="Common.attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="bibentry"/>
          <ref name="bibitem"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <!--
    ======================================================================
    bibitem is the formatted, presentation, form, typically information has been lost;
    it basically contains a biblabel and several bibblock's
    ======================================================================
  -->
  <define name="bibitem">
    <element name="bibitem">
      <a:documentation>A formatted bibliographic item, typically as written explicit
in a LaTeX article. This has generally lost most of the semantics
present in the BibTeX data.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="ID.attributes"/>
      <optional>
        <attribute name="key">
          <a:documentation>The unique key for this object; this key is referenced by the
\attr{bibrefs} attribute of \elementref{bibref}.</a:documentation>
        </attribute>
      </optional>
      <zeroOrMore>
        <ref name="bibtag"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="bibblock"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="bibtag">
    <element name="bibtag">
      <a:documentation>Various formatted tags for bibliographic items.
Typically @role refnum is shown in the displayed bibliography,
as the beginning of the item.  Other roles 
(eg. number, authors, fullauthors, year, title) record formatted
info to be used for filling in citations (\elementref{bibref}).</a:documentation>
      <optional>
        <attribute name="role">
          <choice>
            <value>number</value>
            <value>authors</value>
            <value>fullauthors</value>
            <value>key</value>
            <value>year</value>
            <value>bibtype</value>
            <value>title</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="open">
          <a:documentation>A delimiter for formatting the refnum in the bibliography</a:documentation>
        </attribute>
      </optional>
      <optional>
        <attribute name="close">
          <a:documentation>A delimiter for formatting the refnum in the bibliography</a:documentation>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bibblock">
    <element name="bibblock">
      <a:documentation>A block of data appearing within a \elementref{bibitem}.</a:documentation>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!--
    ======================================================================
    bibentry is the (more) semantic form, typically extracted from bibtex.
    ======================================================================
  -->
  <define name="bibentry">
    <element name="bibentry">
      <a:documentation>Semantic representation of a bibliography entry, 
typically resulting from parsing BibTeX</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="ID.attributes"/>
      <attribute name="key">
        <a:documentation>The unique key for this object; this key is referenced by the
\attr{bibrefs} attribute of \elementref{bibref}.</a:documentation>
      </attribute>
      <attribute name="type">
        <a:documentation>The type of the referenced object. The values are a superset of
those types recognized by BibTeX, but is also open-ended for extensibility.</a:documentation>
        <ref name="bibentry.type"/>
      </attribute>
      <zeroOrMore>
        <ref name="Bibentry.class"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="bibentry.type">
    <choice>
      <value>article</value>
      <value>book</value>
      <value>booklet</value>
      <value>conference</value>
      <value>inbook</value>
      <value>incollection</value>
      <value>inproceedings</value>
      <value>manual</value>
      <value>mastersthesis</value>
      <value>misc</value>
      <value>phdthesis</value>
      <value>proceedings</value>
      <value>techreport</value>
      <value>unpublished</value>
      <value>report</value>
      <value>thesis</value>
      <value>website</value>
      <value>software</value>
      <value>periodical</value>
      <value>collection</value>
      <value>collection.article</value>
      <value>proceedings.article</value>
      <text/>
    </choice>
  </define>
  <!--
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Name related information
  -->
  <define name="bib-name">
    <element name="bib-name">
      <a:documentation>Name of some participant in creating a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>The role that this participant played in creating the entry.</a:documentation>
          <choice>
            <value>author</value>
            <value>editor</value>
            <value>translator</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Bibname.model"/>
    </element>
  </define>
  <define name="Bibname.model">
    <a:documentation>The content model of the bibliographic name fields (\elementref{bib-name})</a:documentation>
    <ref name="surname"/>
    <optional>
      <ref name="givenname"/>
    </optional>
    <optional>
      <ref name="lineage"/>
    </optional>
  </define>
  <define name="surname">
    <element name="surname">
      <a:documentation>Surname of a participant (\elementref{bib-name}).</a:documentation>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="givenname">
    <element name="givenname">
      <a:documentation>Given name of a participant (\elementref{bib-name}).</a:documentation>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="lineage">
    <element name="lineage">
      <a:documentation>Lineage of a participant (\elementref{bib-name}), eg. Jr. or similar.</a:documentation>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!--
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Title related information
  -->
  <define name="bib-title">
    <element name="bib-title">
      <a:documentation>Title of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-subtitle">
    <element name="bib-subtitle">
      <a:documentation>Subtitle of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-key">
    <element name="bib-key">
      <a:documentation>Unique key of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-type">
    <element name="bib-type">
      <a:documentation>Type of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-date">
    <element name="bib-date">
      <a:documentation>Date of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>characterizes what happened on the given date</a:documentation>
          <choice>
            <value>publication</value>
            <value>copyright</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-publisher">
    <element name="bib-publisher">
      <a:documentation>Publisher of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-organization">
    <element name="bib-organization">
      <a:documentation>Organization responsible for a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-place">
    <element name="bib-place">
      <a:documentation>Location of publisher or event</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="bib-related">
    <element name="bib-related">
      <a:documentation>A Related bibliographic object, such as the book or journal
that the current item is related to.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="type">
          <a:documentation>The type of this related entry.</a:documentation>
          <ref name="bibentry.type"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="role">
          <a:documentation>How this object relates to the containing object.
Particularly important is \attrval{host} which indicates that
the outer object is a part of this object.</a:documentation>
          <choice>
            <value>host</value>
            <value>event</value>
            <value>original</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="bibrefs">
          <a:documentation>If the bibrefs attribute is given, it is the key of another object in the bibliography,
and this element should be empty; otherwise the object should be described by
the content of the element.</a:documentation>
        </attribute>
      </optional>
      <zeroOrMore>
        <ref name="Bibentry.class"/>
      </zeroOrMore>
    </element>
  </define>
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <define name="bib-part">
    <element name="bib-part">
      <a:documentation>Describes how the current object is related to a related (\elementref{bib-related})
object, in particular page, part, volume numbers and similar.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>indicates how the value partitions the containing object.</a:documentation>
          <choice>
            <value>pages</value>
            <value>part</value>
            <value>volume</value>
            <value>issue</value>
            <value>number</value>
            <value>chapter</value>
            <value>section</value>
            <value>paragraph</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <!--
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
  -->
  <define name="bib-edition">
    <element name="bib-edition">
      <a:documentation>Edition of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-status">
    <element name="bib-status">
      <a:documentation>Status of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-identifier">
    <element name="bib-identifier">
      <a:documentation>Some form of document identfier. The content is descriptive.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="scheme">
          <a:documentation>indicates what sort of identifier it is; it is open-ended for extensibility.</a:documentation>
          <choice>
            <value>doi</value>
            <value>issn</value>
            <value>isbn</value>
            <value>mr</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="id">
          <a:documentation>the identifier.</a:documentation>
        </attribute>
      </optional>
      <optional>
        <attribute name="href">
          <a:documentation>a url to the document, if available</a:documentation>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-review">
    <element name="bib-review">
      <a:documentation>Review of a bibliographic entry. The content is descriptive.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="scheme">
          <a:documentation>indicates what sort of identifier it is; it is open-ended for extensibility.</a:documentation>
          <choice>
            <value>doi</value>
            <value>issn</value>
            <value>isbn</value>
            <value>mr</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="id">
          <a:documentation>the identifier.</a:documentation>
        </attribute>
      </optional>
      <optional>
        <attribute name="href">
          <a:documentation>a url to the review, if available</a:documentation>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-links">
    <element name="bib-links">
      <a:documentation>Links to other things like preprints, source code, etc.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-language">
    <element name="bib-language">
      <a:documentation>Language of a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-url">
    <element name="bib-url">
      <a:documentation>A URL for a bibliographic entry. The content is descriptive</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="href"/>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-extract">
    <element name="bib-extract">
      <a:documentation>An extract from the referenced object.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>Classify what kind of extract</a:documentation>
          <choice>
            <value>keywords</value>
            <value>abstract</value>
            <value>contents</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="bib-note">
    <element name="bib-note">
      <a:documentation>Notes about a bibliographic entry.</a:documentation>
      <ref name="Common.attributes"/>
      <optional>
        <attribute name="role">
          <a:documentation>Classify the kind of note</a:documentation>
          <choice>
            <value>annotation</value>
            <value>publication</value>
            <text/>
          </choice>
        </attribute>
      </optional>
      <ref name="Inline.model"/>
    </element>
  </define>
  <define name="Bibentry.class">
    <choice>
      <ref name="bib-name"/>
      <ref name="bib-title"/>
      <ref name="bib-subtitle"/>
      <ref name="bib-key"/>
      <ref name="bib-type"/>
      <ref name="bib-date"/>
      <ref name="bib-publisher"/>
      <ref name="bib-organization"/>
      <ref name="bib-place"/>
      <ref name="bib-part"/>
      <ref name="bib-related"/>
      <ref name="bib-edition"/>
      <ref name="bib-status"/>
      <ref name="bib-language"/>
      <ref name="bib-url"/>
      <ref name="bib-note"/>
      <ref name="bib-extract"/>
      <ref name="bib-identifier"/>
      <ref name="bib-review"/>
      <ref name="bib-links"/>
    </choice>
  </define>
</grammar>
