RelaxNG/publidoc.rng
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 11 juin 2011 12:44:21 +0200
changeset 13 846ec40a5b2d
parent 12 2885b2c3ff59
child 17 ca367d4d080b
permissions -rw-r--r--
Exemples complétés + <date> et <number> améliorés
<?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="metadata"/>
    </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="topic.content"/>
    </element>
  </define>
  <!--
    =============================================================================
                                  Metadata level
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="metadata">
    <element name="metadata">
      <ref name="metadata.content"/>
    </element>
  </define>
  <define name="metadata.content">
    <interleave>
      <ref name="title"/>
      <optional>
        <ref name="subtitle"/>
      </optional>
      <zeroOrMore>
        <ref name="author"/>
      </zeroOrMore>
      <optional>
        <ref name="publisher"/>
      </optional>
      <optional>
        <ref name="language"/>
      </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="title">
    <element name="title">
      <ref name="title.content"/>
    </element>
  </define>
  <define name="title.content">
    <ref name="inlines"/>
  </define>
  <define name="subtitle">
    <element name="subtitle">
      <ref name="title.content"/>
    </element>
  </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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="parag"/>
    </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="metadata"/>
    </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="top.topic.attributes">
    <interleave>
      <ref name="topic.id.attribute"/>
      <optional>
        <ref name="topic.type.attribute"/>
      </optional>
    </interleave>
  </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.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="topic.content">
    <optional>
      <ref name="metadata"/>
    </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="metadata"/>
    </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
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blocks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="block">
    <choice>
      <ref name="parag"/>
      <ref name="list"/>
      <ref name="speech"/>
      <ref name="media"/>
    </choice>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ parag ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="parag">
    <element name="parag">
      <ref name="parag.content"/>
    </element>
  </define>
  <define name="parag.content">
    <interleave>
      <ref name="inlines"/>
      <zeroOrMore>
        <ref name="link"/>
      </zeroOrMore>
    </interleave>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <!-- ~~~~~~ list -->
  <define name="list">
    <element name="list">
      <ref name="list.content"/>
    </element>
  </define>
  <define name="list.content">
    <optional>
      <ref name="title"/>
    </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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="parag"/>
    </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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="media.caption"/>
    </optional>
  </define>
  <define name="media.id.attribute">
    <attribute name="id">
      <data type="NMTOKEN"/>
    </attribute>
  </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="image.content">
    <optional>
      <ref name="copyright"/>
    </optional>
  </define>
  <!-- ~~~~~~ caption -->
  <define name="media.caption">
    <element name="caption">
      <ref name="media.caption.content"/>
    </element>
  </define>
  <define name="media.caption.content">
    <oneOrMore>
      <ref name="parag"/>
    </oneOrMore>
  </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">
    <oneOrMore>
      <ref name="parag"/>
    </oneOrMore>
  </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>