RelaxNG/publiset.rng
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 11 juin 2011 01:26:31 +0200
changeset 11 2b32b535705c
parent 5 69310bc35b63
child 20 79713ffae179
permissions -rw-r--r--
Ajout d'un exemple de citation
<?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="publiset"/>
  </start>
  <define name="publiset">
    <element name="publiset">
      <ref name="publiset.attributes"/>
      <ref name="publiset.content"/>
    </element>
  </define>
  <define name="publiset.attributes">
    <ref name="version.attribute"/>
  </define>
  <define name="version.attribute">
    <attribute name="version">
      <value>1.0</value>
    </attribute>
  </define>
  <define name="publiset.content">
    <oneOrMore>
      <choice>
        <ref name="composition"/>
        <ref name="selection"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                     Top level
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="composition">
    <element name="composition">
      <ref name="composition.attributes"/>
      <ref name="composition.content"/>
    </element>
  </define>
  <define name="composition.attributes">
    <interleave>
      <ref name="composition.id.attribute"/>
      <optional>
        <ref name="base.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="composition.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="base.attribute">
    <attribute name="xml:base">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="composition.content">
    <optional>
      <ref name="composition.metadata"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="composition.file"/>
        <ref name="composition.division"/>
      </choice>
    </oneOrMore>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="selection">
    <element name="selection">
      <ref name="selection.attributes"/>
      <ref name="selection.content"/>
    </element>
  </define>
  <define name="selection.attributes">
    <optional>
      <ref name="base.attribute"/>
    </optional>
  </define>
  <define name="selection.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="selection.content">
    <optional>
      <ref name="selection.metadata"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="selection.file"/>
        <ref name="selection.division"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                    Metadata level
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="composition.metadata">
    <element name="metadata">
      <ref name="metadata.attributes"/>
      <ref name="metadata.content"/>
    </element>
  </define>
  <define name="selection.metadata">
    <element name="metadata">
      <ref name="metadata.content"/>
    </element>
  </define>
  <define name="metadata.attributes">
    <ref name="remap.attributes"/>
  </define>
  <define name="metadata.content">
    <interleave>
      <optional>
        <ref name="title"/>
      </optional>
      <optional>
        <ref name="subtitle"/>
      </optional>
      <zeroOrMore>
        <ref name="author"/>
      </zeroOrMore>
      <optional>
        <ref name="publisher"/>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
      <optional>
        <ref name="source"/>
      </optional>
    </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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>
    </element>
  </define>
  <define name="source.attributes">
    <interleave>
      <optional>
        <ref name="source.id.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="source.id.attribute">
    <attribute name="id">
      <data type="NMTOKEN"/>
    </attribute>
  </define>
  <define name="source.content.book">
    <optional>
      <ref name="title"/>
    </optional>
    <optional>
      <ref name="pagenumber"/>
    </optional>
  </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>
  <!--
    =============================================================================
                                   Division level
    =============================================================================
  -->
  <define name="composition.division">
    <element name="division">
      <ref name="composition.division.attributes"/>
      <ref name="composition.division.content"/>
    </element>
  </define>
  <define name="selection.division">
    <element name="division">
      <ref name="selection.division.attributes"/>
      <ref name="selection.division.content"/>
    </element>
  </define>
  <define name="composition.division.attributes">
    <interleave>
      <optional>
        <ref name="base.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="selection.division.attributes">
    <optional>
      <ref name="base.attribute"/>
    </optional>
  </define>
  <define name="composition.division.content">
    <optional>
      <ref name="composition.metadata"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="composition.file"/>
        <ref name="composition.division"/>
      </choice>
    </oneOrMore>
  </define>
  <define name="selection.division.content">
    <optional>
      <ref name="selection.metadata"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="selection.file"/>
        <ref name="selection.division"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                     File level
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="composition.file">
    <element name="file">
      <ref name="composition.file.attributes"/>
      <ref name="file.content"/>
    </element>
  </define>
  <define name="selection.file">
    <element name="file">
      <ref name="selection.file.attributes"/>
      <ref name="file.content"/>
    </element>
  </define>
  <define name="composition.file.attributes">
    <interleave>
      <optional>
        <ref name="xpath.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="selection.file.attributes">
    <optional>
      <ref name="xpath.attribute"/>
    </optional>
  </define>
  <define name="xpath.attribute">
    <attribute name="xpath"/>
  </define>
  <define name="file.content">
    <data type="anyURI"/>
  </define>
  <!--
    =============================================================================
                                    Inline level
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="inlines">
    <mixed>
      <interleave>
        <zeroOrMore>
          <ref name="sup"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="sub"/>
        </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>
  <!--
    =============================================================================
                                  Remap attributes
    =============================================================================
  -->
  <define name="remap.attributes">
    <interleave>
      <optional>
        <ref name="as.attribute"/>
      </optional>
      <optional>
        <ref name="attributes.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="as.attribute">
    <attribute name="as">
      <data type="QName"/>
    </attribute>
  </define>
  <define name="attributes.attribute">
    <attribute name="attributes">
      <list>
        <oneOrMore>
          <data type="token">
            <param name="pattern">\c+=\S+</param>
          </data>
        </oneOrMore>
      </list>
    </attribute>
  </define>
</grammar>