<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- site -->
  <xsd:element name="site" type="SiteType">
    <xsd:annotation>
      <xsd:documentation>The root element of any Bouchot Config</xsd:documentation>
    </xsd:annotation>
  </xsd:element>
  <!-- /site -->

  <!-- SiteType -->
  <xsd:complexType name="SiteType">
    <xsd:annotation>
      <xsd:documentation>This is the root type of any Bouchot Config</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
      <xsd:element name="alias" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The aliases of this bouchot</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="account" type="AccountType" minOccurs="0">
        <xsd:annotation>
          <xsd:documentation>The cookies and form data to authenticate on the bouchot</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="board" type="BoardModuleType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The description of a board</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="rss" type="RssModuleType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The description of an RSS feed</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="module" type="ModuleType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The description of any other module</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>

    <xsd:attribute name="name" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The short name of the bouchot</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="title" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The full name of the bouchot</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="baseurl" type="xsd:anyURI" use="required">
      <xsd:annotation>
        <xsd:documentation>The base URL of the bouchot. Every further relative url will be relative to that one</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="version" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The version of the configuration format</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- /SiteType -->

  <!-- AccountType -->
  <xsd:complexType name="AccountType">
    <xsd:annotation>
      <xsd:documentation>This type contains the informations to log into the bouchot</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
      <xsd:element name="cookie" type="CookieType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The cookies needed for authentication</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="login" type="LogFormType">
        <xsd:annotation>
          <xsd:documentation>The informations for the login form</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="logout" type="LogFormType">
        <xsd:annotation>
          <xsd:documentation>The informations for the logout form</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <!-- /AccountType -->

  <!-- CookieType -->
  <xsd:complexType name="CookieType">
    <xsd:annotation>
      <xsd:documentation>This type contains the name of a cookie needed for authentication</xsd:documentation>
    </xsd:annotation>

    <xsd:attribute name="name" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The name of the cookie</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
  </xsd:complexType>
  <!-- /CookieType -->

  <!-- LogFormType -->
  <xsd:complexType name="LogFormType">
    <xsd:annotation>
      <xsd:documentation>The structure of the login and logout forms</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
      <xsd:element name="field" type="LogFormFieldType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The fields of the form</xsd:documentation>
      </xsd:annotation>
      </xsd:element>
    </xsd:sequence>

    <xsd:attribute name="path" type="xsd:anyURI" use="required">
      <xsd:annotation>
        <xsd:documentation>The form URL relative to the bouchot's baseurl</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="method" type="MethodType" use="required">
      <xsd:annotation>
        <xsd:documentation>The form URL relative to the bouchot's baseurl</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- /LogFormType -->

  <!-- MethodType -->
  <xsd:simpleType name="MethodType">
    <xsd:restriction base="xsd:string">

      <xsd:enumeration value="get">
        <xsd:annotation>
          <xsd:documentation>Use the HTTP GET method</xsd:documentation>
        </xsd:annotation>
      </xsd:enumeration>

      <xsd:enumeration value="post">
        <xsd:annotation>
          <xsd:documentation>Use the HTTP POST method</xsd:documentation>
        </xsd:annotation>
      </xsd:enumeration>
    </xsd:restriction>
  </xsd:simpleType>
  <!-- /MethodType -->

  <!-- FormFieldType -->
  <xsd:complexType name="FormFieldType">
    <xsd:annotation>
      <xsd:documentation>Description of a form field</xsd:documentation>
    </xsd:annotation>

    <xsd:simpleContent>
      <xsd:extension base="xsd:string">

        <xsd:attribute name="name" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>The name of the field</xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>

      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  <!-- /FormFieldType -->

  <!-- LogFormFieldType -->
  <xsd:complexType name="LogFormFieldType">
    <xsd:annotation>
      <xsd:documentation>Description of a login or logout form field</xsd:documentation>
    </xsd:annotation>

    <xsd:simpleContent>
      <xsd:extension base="FormFieldType">

        <xsd:attribute name="title" type="xsd:string" use="required">
          <xsd:annotation>
            <xsd:documentation>The full name of the field (for presentation)</xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>

      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  <!-- /LogFormFieldType -->

  <!-- ModuleType -->
  <xsd:complexType name="ModuleType" abstract="false">
    <xsd:annotation>
      <xsd:documentation>This is the base type for modules (board, rss, forum, persinfo...)</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
      <xsd:element name="option" type="OptionType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation></xsd:annotation>
      </xsd:element>
    </xsd:sequence>

    <xsd:attribute name="name" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The short name of the module</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="title" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The full name of the module</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- /ModuleType -->

  <!-- OptionType -->
  <xsd:complexType name="OptionType">
    <xsd:annotation>
      <xsd:documentation>An option of a module</xsd:documentation>
    </xsd:annotation>

    <xsd:simpleContent>
      <xsd:extension base="xsd:string">

        <xsd:attribute name="name" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>The name of the option</xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>

      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  <!-- /OptionType -->

  <!-- BoardModuleType -->
  <xsd:complexType name="BoardModuleType">
    <xsd:annotation>
      <xsd:documentation>Ajouts pour le module de type board</xsd:documentation>
    </xsd:annotation>

    <xsd:complexContent>
      <xsd:restriction base="ModuleType">
        <xsd:sequence>

          <xsd:element name="backend" type="BackendType">
            <xsd:annotation>
              <xsd:documentation>The informations about the backend</xsd:documentation>
            </xsd:annotation>
          </xsd:element>

          <xsd:element name="post" type="PostType">
            <xsd:annotation>
              <xsd:documentation>The informations to send the messages</xsd:documentation>
            </xsd:annotation>
          </xsd:element>

        </xsd:sequence>

      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
  <!-- /BoardModuleType -->

  <!-- BackendType -->
  <xsd:complexType name="BackendType">
    <xsd:annotation>
      <xsd:documentation>The informations about the backend</xsd:documentation>
    </xsd:annotation>

    <xsd:attribute name="public" type="xsd:boolean" use="optional" default="true">
      <xsd:annotation>
        <xsd:documentation>Tells whether the backend is public (no authentication needed) or private (authentication needed)</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="path" type="xsd:anyURI" use="required">
      <xsd:annotation>
        <xsd:documentation>The URL of the backend file (relative or absolute)</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="tags_encoded" type="xsd:boolean" use="optional" default="false">
      <xsd:annotation>
        <xsd:documentation>Tells wethers the tags in a message are encoded or not</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="refresh" type="xsd:integer" use="optional">
      <xsd:annotation>
        <xsd:documentation>The refresh rate in seconds recommended by the server</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- /BackendType -->

  <!-- PostType -->
  <xsd:complexType name="PostType">
    <xsd:annotation>
      <xsd:documentation>The informations of the post form used the messages</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>

      <xsd:element name="field" type="FormFieldType" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The fields of the post form</xsd:documentation>
        </xsd:annotation>
      </xsd:element>

    </xsd:sequence>

    <xsd:attribute name="anonymous" type="xsd:boolean" use="optional" default="true">
      <xsd:annotation>
        <xsd:documentation>Tells whether one can post as anonymous (else, authentication is needed)</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="path" type="xsd:anyURI" use="required">
      <xsd:annotation>
        <xsd:documentation>The URL to post (relative or absolute)</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="method" type="MethodType" use="required">
      <xsd:annotation>
        <xsd:documentation>The HTTP method to use</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="max_length" type="xsd:integer" use="optional">
      <xsd:annotation>
        <xsd:documentation>The maximum length of the message recommended by the server</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- PostType -->

  <!-- RssModuleType -->
  <xsd:complexType name="RssModuleType">
    <xsd:annotation>
      <xsd:documentation>Ajouts pour le module de type rss</xsd:documentation>
    </xsd:annotation>

    <xsd:complexContent>
      <xsd:restriction base="ModuleType">
        <xsd:sequence>

          <xsd:element name="link" type="LinkType" maxOccurs="unbounded">
            <xsd:annotation>
              <xsd:documentation>The links to various RSS streams</xsd:documentation>
            </xsd:annotation>
          </xsd:element>

        </xsd:sequence>

      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
  <!-- /RssModuleType -->

  <!-- LinkType -->
  <xsd:complexType name="LinkType">
    <xsd:annotation>
      <xsd:documentation>Where to find a file</xsd:documentation>
    </xsd:annotation>

    <xsd:attribute name="path" type="xsd:anyURI" use="required">
      <xsd:annotation>
        <xsd:documentation>The URL of the file</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

    <xsd:attribute name="title" type="xsd:string" use="required">
      <xsd:annotation>
        <xsd:documentation>The description of the file</xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>

  </xsd:complexType>
  <!-- /LinkType -->

</xsd:schema>
