RelaxNG/publiset.rng
author Patrick PIERRE <patrick.pierre@prismallia.fr>
lun., 18 juil. 2011 19:10:28 +0200
changeset 33 c70de8fae29d
parent 30 c0f9e813c039
child 34 c51d5097d065
permissions -rw-r--r--
Ajout d'un role pour les auteurs
<?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="path.attribute"/>
      </optional>
      <optional>
        <ref name="xpath.attribute"/>
      </optional>
      <optional>
        <ref name="xslt.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="composition.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="path.attribute">
    <attribute name="path">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="xslt.attribute">
    <attribute name="xslt">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="xpath.attribute">
    <attribute name="xpath"/>
  </define>
  <define name="composition.content">
    <optional>
      <ref name="composition.head"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="composition.division"/>
        <ref name="composition.file"/>
      </choice>
    </oneOrMore>
  </define>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="selection">
    <element name="selection">
      <ref name="selection.attributes"/>
      <ref name="selection.content"/>
    </element>
  </define>
  <define name="selection.attributes">
    <interleave>
      <ref name="selection.id.attribute"/>
      <optional>
        <ref name="path.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="selection.id.attribute">
    <attribute name="xml:id">
      <data type="ID"/>
    </attribute>
  </define>
  <define name="selection.content">
    <optional>
      <ref name="selection.head"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="selection.division"/>
        <ref name="selection.file"/>
        <ref name="link"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                     HEAD LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="composition.head">
    <element name="head">
      <ref name="head.attributes"/>
      <ref name="top.head.content"/>
    </element>
  </define>
  <define name="selection.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="head.attributes">
    <ref name="remap.attributes"/>
  </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="source"/>
      </optional>
    </interleave>
  </define>
  <define name="division.head.content">
    <interleave>
      <optional>
        <ref name="title"/>
        <optional>
          <ref name="subtitle"/>
        </optional>
      </optional>
      <optional>
        <ref name="language"/>
      </optional>
    </interleave>
  </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>
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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="path.attribute"/>
      </optional>
      <optional>
        <ref name="xpath.attribute"/>
      </optional>
      <optional>
        <ref name="xslt.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="selection.division.attributes">
    <optional>
      <ref name="path.attribute"/>
    </optional>
  </define>
  <define name="composition.division.content">
    <optional>
      <ref name="composition.head"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="composition.division"/>
        <ref name="composition.file"/>
      </choice>
    </oneOrMore>
  </define>
  <define name="selection.division.content">
    <optional>
      <ref name="selection.head"/>
    </optional>
    <oneOrMore>
      <choice>
        <ref name="selection.division"/>
        <ref name="selection.file"/>
        <ref name="link"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    =============================================================================
                                     FILE LEVEL
    =============================================================================
  -->
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <define name="composition.file">
    <element name="file">
      <ref name="composition.file.attributes"/>
    </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>
      <ref name="name.attribute"/>
      <optional>
        <ref name="xpath.attribute"/>
      </optional>
      <optional>
        <ref name="xslt.attribute"/>
      </optional>
      <ref name="remap.attributes"/>
    </interleave>
  </define>
  <define name="selection.file.attributes">
    <interleave>
      <ref name="name.attribute"/>
      <optional>
        <ref name="uri.attribute"/>
      </optional>
    </interleave>
  </define>
  <define name="name.attribute">
    <attribute name="name">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="uri.attribute">
    <attribute name="uri">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="file.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">
    <ref name="uri.attribute"/>
  </define>
  <define name="link.content">
    <ref name="inlines"/>
  </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>