<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <!-- $Id$ -->
  <start>
    <ref name="publidoc"/>
  </start>
  <define name="publidoc">
    <element name="publidoc">
      <ref name="publidoc.attributes"/>
      <ref name="publidoc.content"/>
    </element>
  </define>
  <define name="publidoc.attributes">
    <ref name="version.attribute"/>
  </define>
  <define name="version.attribute">
    <attribute name="version">
      <value>1.0</value>
    </attribute>
  </define>
  <define name="publidoc.content">
    <choice>
      <ref name="document"/>
      <ref name="top.topic"/>
    </choice>
  </define>
  <!--
    =============================================================================
                                     TOP LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ document ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="document">
    <element name="document">
      <ref name="document.attributes"/>
      <ref name="document.content"/>
    </element>
  </define>
  <define name="document.attributes">
    <ref name="document.id.attribute"/>
  </define>
  <define name="document.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="document.content">
    <optional>
      <ref name="top.head"/>
    </optional>
    <choice>
      <oneOrMore>
        <ref name="division"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="topic"/>
      </oneOrMore>
    </choice>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="top.topic">
    <element name="topic">
      <ref name="top.topic.attributes"/>
      <ref name="top.topic.content"/>
    </element>
  </define>
  <define name="top.topic.attributes">
    <interleave>
      <ref name="topic.id.attribute"/>
      <optional>
        <ref name="topic.type.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="topic.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="topic.type.attribute">
    <attribute name="type">
      <data type="NCName"/>
    </attribute>
  </define>
  <define name="top.topic.content">
    <optional>
      <ref name="top.head"/>
    </optional>
    <oneOrMore>
      <ref name="section"/>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                    HEAD LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="top.head">
    <element name="head">
      <ref name="top.head.content"/>
    </element>
  </define>
  <define name="division.head">
    <element name="head">
      <ref name="division.head.content"/>
    </element>
  </define>
  <define name="component.head">
    <element name="head">
      <ref name="component.head.content"/>
    </element>
  </define>
  <define name="section.head">
    <element name="head">
      <ref name="section.head.content"/>
    </element>
  </define>
  <define name="block.head">
    <element name="head">
      <ref name="block.head.content"/>
    </element>
  </define>
  <define name="top.head.content">
    <interleave>
      <optional>
        <ref name="title"/>
        <optional>
          <ref name="subtitle"/>
        </optional>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
      <zeroOrMore>
        <ref name="author"/>
      </zeroOrMore>
      <optional>
        <ref name="publisher"/>
      </optional>
      <optional>
        <ref name="date"/>
      </optional>
      <optional>
        <ref name="place"/>
      </optional>
      <zeroOrMore>
        <ref name="source"/>
      </zeroOrMore>
      <optional>
        <ref name="subjectset"/>
      </optional>
      <optional>
        <ref name="abstract"/>
      </optional>
      <zeroOrMore>
        <ref name="annotation"/>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="division.head.content">
    <interleave>
      <optional>
        <ref name="title"/>
        <optional>
          <ref name="subtitle"/>
        </optional>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
      <zeroOrMore>
        <ref name="annotation"/>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="component.head.content">
    <interleave>
      <optional>
        <ref name="title"/>
        <optional>
          <ref name="subtitle"/>
        </optional>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
      <zeroOrMore>
        <ref name="author"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="annotation"/>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="section.head.content">
    <interleave>
      <optional>
        <ref name="title"/>
        <optional>
          <ref name="subtitle"/>
        </optional>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
      <zeroOrMore>
        <ref name="annotation"/>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="block.head.content">
    <optional>
      <ref name="title"/>
      <optional>
        <ref name="subtitle"/>
      </optional>
    </optional>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="title">
    <element name="title">
      <ref name="title.content"/>
    </element>
  </define>
  <define name="subtitle">
    <element name="subtitle">
      <ref name="title.content"/>
    </element>
  </define>
  <define name="title.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="language">
    <element name="language">
      <ref name="language.attributes"/>
    </element>
  </define>
  <define name="language.attributes">
    <ref name="lang.attribute"/>
  </define>
  <define name="lang.attribute">
    <attribute name="xml:lang">
      <data type="language"/>
    </attribute>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ author -->
  <define name="author">
    <element name="author">
      <ref name="author.content"/>
    </element>
  </define>
  <define name="author.content">
    <optional>
      <ref name="firstname"/>
    </optional>
    <ref name="lastname"/>
  </define>
  <!-- ~~~~~~ publisher -->
  <define name="publisher">
    <element name="publisher">
      <ref name="publisher.content"/>
    </element>
  </define>
  <define name="publisher.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~ firstname -->
  <define name="firstname">
    <element name="firstname">
      <ref name="firstname.content"/>
    </element>
  </define>
  <define name="firstname.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~ lastname -->
  <define name="lastname">
    <element name="lastname">
      <ref name="lastname.content"/>
    </element>
  </define>
  <define name="lastname.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ place ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="place">
    <element name="place">
      <ref name="place.content"/>
    </element>
  </define>
  <define name="place.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ source -->
  <define name="source">
    <element name="source">
      <ref name="source.attributes"/>
      <choice>
        <group>
          <attribute name="type">
            <value>book</value>
          </attribute>
          <ref name="source.content.book"/>
        </group>
        <attribute name="type">
          <value>file</value>
        </attribute>
      </choice>
      <ref name="source.content"/>
    </element>
  </define>
  <define name="source.attributes">
    <ref name="source.id.attribute"/>
  </define>
  <define name="source.id.attribute">
    <attribute name="id">
      <data type="NMTOKEN"/>
    </attribute>
  </define>
  <define name="source.content.book">
    <ref name="title"/>
    <zeroOrMore>
      <ref name="pagenumber"/>
    </zeroOrMore>
  </define>
  <define name="source.content">
    <zeroOrMore>
      <ref name="annotation"/>
    </zeroOrMore>
  </define>
  <!-- ~~~~~~ pagenumber -->
  <define name="pagenumber">
    <element name="pagenumber">
      <ref name="pagenumber.attributes"/>
    </element>
  </define>
  <define name="pagenumber.attributes">
    <ref name="pagenumber.value.attribute"/>
  </define>
  <define name="pagenumber.value.attribute">
    <attribute name="value">
      <ref name="pagenumber.value.enumeration"/>
    </attribute>
  </define>
  <define name="pagenumber.value.enumeration">
    <data type="positiveInteger"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ subjectset -->
  <define name="subjectset">
    <element name="subjectset">
      <ref name="subjectset.content"/>
    </element>
  </define>
  <define name="subjectset.content">
    <oneOrMore>
      <ref name="subject"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ subject -->
  <define name="subject">
    <element name="subject">
      <ref name="subject.attributes"/>
    </element>
  </define>
  <define name="subject.attributes">
    <ref name="subject.id.attribute"/>
  </define>
  <define name="subject.id.attribute">
    <attribute name="id">
      <data type="NMTOKEN"/>
    </attribute>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="abstract">
    <element name="abstract">
      <ref name="abstract.content"/>
    </element>
  </define>
  <define name="abstract.content">
    <oneOrMore>
      <ref name="p"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ annotation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="annotation">
    <element name="annotation">
      <ref name="annotation.content"/>
    </element>
  </define>
  <define name="annotation.content">
    <ref name="inlines"/>
  </define>
  <!--
    =============================================================================
                                    DIVISION LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="division">
    <element name="division">
      <ref name="division.content"/>
    </element>
  </define>
  <define name="division.content">
    <optional>
      <ref name="division.head"/>
    </optional>
    <choice>
      <oneOrMore>
        <ref name="division"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="topic"/>
      </oneOrMore>
    </choice>
  </define>
  <!--
    =============================================================================
                                  COMPONENT LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="topic">
    <element name="topic">
      <ref name="topic.attributes"/>
      <ref name="topic.content"/>
    </element>
  </define>
  <define name="topic.attributes">
    <interleave>
      <optional>
        <ref name="topic.id.attribute"/>
      </optional>
      <optional>
        <ref name="topic.type.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="topic.content">
    <optional>
      <ref name="component.head"/>
    </optional>
    <oneOrMore>
      <ref name="section"/>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                    SECTION LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="section">
    <element name="section">
      <ref name="section.content"/>
      <ref name="section.attributes"/>
    </element>
  </define>
  <define name="section.content">
    <optional>
      <ref name="section.head"/>
    </optional>
    <choice>
      <oneOrMore>
        <ref name="section"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="block"/>
      </oneOrMore>
    </choice>
  </define>
  <define name="section.attributes">
    <optional>
      <ref name="status.attribute"/>
    </optional>
  </define>
  <define name="status.attribute">
    <attribute name="status">
      <data type="NCName"/>
    </attribute>
  </define>
  <!--
    =============================================================================
                                    BLOCK LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="block">
    <choice>
      <ref name="p"/>
      <ref name="speech"/>
      <ref name="list"/>
      <ref name="table"/>
      <ref name="media"/>
    </choice>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="p">
    <element name="p">
      <ref name="p.content"/>
    </element>
  </define>
  <define name="p.content">
    <interleave>
      <ref name="inlines"/>
      <zeroOrMore>
        <ref name="link"/>
      </zeroOrMore>
    </interleave>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ speech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ speech -->
  <define name="speech">
    <element name="speech">
      <ref name="speech.content"/>
    </element>
  </define>
  <define name="speech.content">
    <optional>
      <ref name="speaker"/>
    </optional>
    <optional>
      <ref name="stage"/>
    </optional>
    <oneOrMore>
      <ref name="p"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ speaker -->
  <define name="speaker">
    <element name="speaker">
      <ref name="speaker.content"/>
    </element>
  </define>
  <define name="speaker.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~ stage -->
  <define name="stage">
    <element name="stage">
      <ref name="stage.content"/>
    </element>
  </define>
  <define name="stage.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ list -->
  <define name="list">
    <element name="list">
      <ref name="list.content"/>
    </element>
  </define>
  <define name="list.content">
    <optional>
      <ref name="block.head"/>
    </optional>
    <choice>
      <group>
        <optional>
          <attribute name="type">
            <value>ordered</value>
          </attribute>
        </optional>
        <ref name="item"/>
        <oneOrMore>
          <ref name="item"/>
        </oneOrMore>
      </group>
      <group>
        <attribute name="type">
          <value>glossary</value>
        </attribute>
        <oneOrMore>
          <ref name="glossary.item"/>
        </oneOrMore>
      </group>
    </choice>
  </define>
  <!-- ~~~~~~ item -->
  <define name="item">
    <element name="item">
      <ref name="item.content"/>
    </element>
  </define>
  <define name="item.content">
    <oneOrMore>
      <ref name="block"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ glossary.item -->
  <define name="glossary.item">
    <element name="item">
      <ref name="glossary.item.content"/>
    </element>
  </define>
  <define name="glossary.item.content">
    <ref name="label"/>
    <oneOrMore>
      <ref name="block"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ label -->
  <define name="label">
    <element name="label">
      <ref name="label.content"/>
    </element>
  </define>
  <define name="label.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="table">
    <element name="table">
      <ref name="table.content"/>
    </element>
  </define>
  <define name="table.content">
    <optional>
      <ref name="block.head"/>
    </optional>
    <oneOrMore>
      <ref name="tgroup"/>
    </oneOrMore>
    <optional>
      <ref name="caption"/>
    </optional>
  </define>
  <!-- ~~~~~~ tgroup -->
  <define name="tgroup">
    <element name="tgroup">
      <ref name="tgroup.attributes"/>
      <ref name="tgroup.content"/>
    </element>
  </define>
  <define name="tgroup.content">
    <optional>
      <ref name="thead"/>
    </optional>
    <optional>
      <ref name="tfoot"/>
    </optional>
    <ref name="tbody"/>
  </define>
  <define name="tgroup.attributes">
    <interleave>
      <ref name="cols.attribute"/>
      <optional>
        <ref name="align.attribute"/>
      </optional>
      <optional>
        <ref name="colsep.attribute"/>
      </optional>
      <optional>
        <ref name="rowsep.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="cols.attribute">
    <attribute name="cols">
      <data type="positiveInteger"/>
    </attribute>
  </define>
  <define name="align.attribute">
    <attribute name="align">
      <choice>
        <value>left</value>
        <value>right</value>
        <value>center</value>
        <value>justify</value>
      </choice>
    </attribute>
  </define>
  <define name="colsep.attribute">
    <attribute name="colsep">
      <choice>
        <value>0</value>
        <value>1</value>
      </choice>
    </attribute>
  </define>
  <define name="rowsep.attribute">
    <attribute name="rowsep">
      <choice>
        <value>0</value>
        <value>1</value>
      </choice>
    </attribute>
  </define>
  <!-- ~~~~~~ thead, tfoot, tbody -->
  <define name="thead">
    <element name="thead">
      <ref name="thead.content"/>
    </element>
  </define>
  <define name="tfoot">
    <element name="tfoot">
      <ref name="tfoot.content"/>
    </element>
  </define>
  <define name="tbody">
    <element name="tbody">
      <ref name="tbody.content"/>
    </element>
  </define>
  <define name="thead.content">
    <oneOrMore>
      <ref name="row"/>
    </oneOrMore>
  </define>
  <define name="tfoot.content">
    <oneOrMore>
      <ref name="row"/>
    </oneOrMore>
  </define>
  <define name="tbody.content">
    <oneOrMore>
      <ref name="row"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ row -->
  <define name="row">
    <element name="row">
      <ref name="row.attribute"/>
      <ref name="row.content"/>
    </element>
  </define>
  <define name="row.attribute">
    <optional>
      <ref name="valign.attribute"/>
    </optional>
  </define>
  <define name="valign.attribute">
    <attribute name="valign">
      <choice>
        <value>top</value>
        <value>middle</value>
        <value>bottom</value>
      </choice>
    </attribute>
  </define>
  <define name="row.content">
    <oneOrMore>
      <ref name="entry"/>
    </oneOrMore>
  </define>
  <!-- ~~~~~~ entry -->
  <define name="entry">
    <element name="entry">
      <ref name="entry.content"/>
    </element>
  </define>
  <define name="entry.content">
    <choice>
      <ref name="inlines"/>
      <oneOrMore>
        <ref name="p"/>
      </oneOrMore>
    </choice>
  </define>
  <!-- ~~~~~~ caption -->
  <define name="caption">
    <element name="caption">
      <ref name="caption.content"/>
    </element>
  </define>
  <define name="caption.content">
    <choice>
      <ref name="inlines"/>
      <oneOrMore>
        <ref name="p"/>
      </oneOrMore>
    </choice>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ media ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ media -->
  <define name="media">
    <element name="media">
      <ref name="media.content"/>
    </element>
  </define>
  <define name="media.content">
    <oneOrMore>
      <ref name="image"/>
    </oneOrMore>
    <optional>
      <ref name="caption"/>
    </optional>
  </define>
  <!-- ~~~~~~ image -->
  <define name="image">
    <element name="image">
      <ref name="image.attributes"/>
      <ref name="image.content"/>
    </element>
  </define>
  <define name="image.attributes">
    <ref name="media.id.attribute"/>
  </define>
  <define name="media.id.attribute">
    <attribute name="id">
      <data type="NMTOKEN"/>
    </attribute>
  </define>
  <define name="image.content">
    <optional>
      <ref name="copyright"/>
    </optional>
  </define>
  <!-- ~~~~~~ copyright -->
  <define name="copyright">
    <element name="copyright">
      <ref name="copyright.content"/>
    </element>
  </define>
  <define name="copyright.content">
    <ref name="inlines"/>
  </define>
  <!--
    =============================================================================
                                    INLINE LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="inlines">
    <mixed>
      <interleave>
        <zeroOrMore>
          <ref name="sup"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="sub"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="number"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="date"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="name"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="note"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="foreign"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="highlight"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="mentioned"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="quote"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="acronym"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="term"/>
        </zeroOrMore>
      </interleave>
    </mixed>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="sup">
    <element name="sup">
      <ref name="inlines"/>
    </element>
  </define>
  <define name="sub">
    <element name="sub">
      <ref name="inlines"/>
    </element>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ number ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="number">
    <element name="number">
      <choice>
        <group>
          <attribute name="type">
            <value>roman</value>
          </attribute>
          <ref name="number.attributes"/>
          <ref name="number.roman.content"/>
        </group>
        <group>
          <ref name="number.attributes"/>
          <ref name="number.content"/>
        </group>
      </choice>
    </element>
  </define>
  <define name="number.attributes">
    <optional>
      <ref name="number.value.attribute"/>
    </optional>
  </define>
  <define name="number.value.attribute">
    <attribute name="value">
      <choice>
        <data type="integer"/>
        <data type="decimal"/>
      </choice>
    </attribute>
  </define>
  <define name="number.content">
    <mixed>
      <zeroOrMore>
        <ref name="sup"/>
      </zeroOrMore>
    </mixed>
  </define>
  <define name="number.roman.content">
    <data type="token">
      <param name="pattern">[dlxvi]+</param>
    </data>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="date">
    <element name="date">
      <ref name="date.attributes"/>
      <ref name="date.content"/>
    </element>
  </define>
  <define name="date.attributes">
    <interleave>
      <ref name="date.value.attribute"/>
      <optional>
        <ref name="date.of.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="date.value.attribute">
    <attribute name="value">
      <choice>
        <data type="date"/>
        <data type="gYearMonth"/>
        <data type="gYear"/>
      </choice>
    </attribute>
  </define>
  <define name="date.of.attribute">
    <attribute name="of">
      <ref name="date.of.enumeration"/>
    </attribute>
  </define>
  <define name="date.of.enumeration">
    <choice>
      <value>birth</value>
      <value>death</value>
    </choice>
  </define>
  <define name="date.content">
    <mixed>
      <zeroOrMore>
        <ref name="sup"/>
      </zeroOrMore>
    </mixed>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="name">
    <element name="name">
      <ref name="name.attributes"/>
      <ref name="name.content"/>
    </element>
  </define>
  <define name="name.attributes">
    <optional>
      <ref name="name.of.attribute"/>
    </optional>
  </define>
  <define name="name.of.attribute">
    <attribute name="of">
      <ref name="name.of.enumeration"/>
    </attribute>
  </define>
  <define name="name.of.enumeration">
    <choice>
      <value>person</value>
      <value>company</value>
      <value>book</value>
      <value>newspaper</value>
      <value>party</value>
    </choice>
  </define>
  <define name="name.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="note">
    <element name="note">
      <ref name="note.attributes"/>
      <ref name="note.content"/>
    </element>
  </define>
  <define name="note.attributes">
    <optional>
      <ref name="note.label.attribute"/>
    </optional>
  </define>
  <define name="note.label.attribute">
    <attribute name="label"/>
  </define>
  <define name="note.content">
    <choice>
      <ref name="inlines"/>
      <oneOrMore>
        <ref name="p"/>
      </oneOrMore>
    </choice>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foreign ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="foreign">
    <element name="foreign">
      <ref name="foreign.attributes"/>
      <ref name="foreign.content"/>
    </element>
  </define>
  <define name="foreign.attributes">
    <optional>
      <ref name="lang.attribute"/>
    </optional>
  </define>
  <define name="foreign.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="highlight">
    <element name="highlight">
      <ref name="highlight.content"/>
    </element>
  </define>
  <define name="highlight.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mentioned ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="mentioned">
    <element name="mentioned">
      <ref name="mentioned.content"/>
    </element>
  </define>
  <define name="mentioned.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quote ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="quote">
    <element name="quote">
      <ref name="quote.content"/>
    </element>
  </define>
  <define name="quote.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ acronym ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="acronym">
    <element name="acronym">
      <ref name="acronym.content"/>
    </element>
  </define>
  <define name="acronym.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ term ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="term">
    <element name="term">
      <ref name="term.content"/>
    </element>
  </define>
  <define name="term.content">
    <ref name="inlines"/>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="link">
    <element name="link">
      <ref name="link.attributes"/>
      <ref name="link.content"/>
    </element>
  </define>
  <define name="link.attributes">
    <optional>
      <choice>
        <ref name="uri.attribute"/>
        <ref name="idref.attribute"/>
      </choice>
    </optional>
  </define>
  <define name="uri.attribute">
    <attribute name="uri">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="idref.attribute">
    <attribute name="idref">
      <data type="IDREF"/>
    </attribute>
  </define>
  <define name="link.content">
    <ref name="inlines"/>
  </define>
</grammar>
