<?xml version="1.0" encoding="utf-8" ?>
<!-- ============================================================================= -->
<!-- Projet   : PMWS                                                               -->
<!-- Fichier  : tree.rng                                                           -->
<!-- Création : 06.01.2011                                                         -->
<!-- Révision : 08.01.2011                                                         -->
<!-- Objet    : schéma Relax NG des fichiers de définition de l'arborescence       -->
<!-- ============================================================================= -->
<!-- Documentation :                                                               -->
<!--                                                                               -->
<!-- RELAX NG Tutorial                                                             -->
<!-- http://www.relaxng.org/tutorial-20011203.html                                 -->
<!--                                                                               -->
<!-- XML Schema schema for XML Schemas: Part 2: Datatypes                          -->
<!-- http://www.w3.org/2001/XMLSchema-datatypes                                    -->
<!-- ============================================================================= -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

   <include href="../rng/types.rng" />

   <start>
      <element name="trees">
         <optional>
            <attribute name="version">
               <choice>
                  <value>1</value>
               </choice>
            </attribute>
         </optional>
         <oneOrMore>
            <element name="tree">
               <attribute name="tree_id">
                  <data type="nonNegativeInteger">
                     <param name="pattern">[0-9]+</param>
                  </data>
               </attribute>
               <optional>
                  <attribute name="maxdepth">
                     <data type="positiveInteger" />
                  </attribute>
               </optional>
               <ref name="seo" />
               <zeroOrMore>
                  <ref name="page" />
               </zeroOrMore>
            </element>
         </oneOrMore>
         <optional>
            <element name="created">
               <ref name="dt_timestamp" />
            </element>
         </optional>

         <optional>
            <element name="lastmod">
               <ref name="dt_timestamp" />
            </element>
         </optional>
         <element name="armor">
            <data type="hexBinary">
               <param name="length">16</param>
            </data>
         </element>
      </element>
   </start>

   <define name="seo">
      <zeroOrMore>
         <element name="keywords">
            <attribute name="lang">
               <ref name="dt_langs_client" />
            </attribute>
            <text />
         </element>
      </zeroOrMore>
      <zeroOrMore>
         <element name="description">
            <attribute name="lang">
               <ref name="dt_langs_client" />
            </attribute>
            <text />
         </element>
      </zeroOrMore>
   </define>

   <define name="page">
      <element name="page">
         <attribute name="page_id">
            <ref name="dt_page_id" />
         </attribute>
         <attribute name="rank">
            <data type="positiveInteger" />
         </attribute>
         <attribute name="type">
            <choice>
               <value>client</value>
               <value>cms</value>
               <value>contact</value>
               <value>search</value>
               <value>sitemap</value>
            </choice>
         </attribute>
         <optional>
            <attribute name="realm">
               <ref name="dt_realm_id" />
            </attribute>
         </optional>
         <oneOrMore><!-- TODO: comment imposer un nombre de balises identiques au nombre de langues ? -->
            <element name="title">
               <attribute name="lang">
                  <ref name="dt_langs_client" />
               </attribute>
               <text />
            </element>
         </oneOrMore>
         <ref name="seo" />
         <zeroOrMore>
            <ref name="page" /><!-- TODO: comment limiter la profondeur de récursion ? -->
         </zeroOrMore>
      </element>
   </define>
</grammar>
