<?xml version="1.0" encoding="UTF-8"?>
<grammar
  xmlns="http://relaxng.org/ns/structure/1.0"
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  xmlns:doc="http://xmlns.4suite.org/doc"
  xmlns:ns="http://xmlns.4suite.org/4ss/properties#"
>

  <start>
    <element ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="RDF">
      <doc:desc>The RDF envelope. 4Suite repo config files are valid RDF/XML files.</doc:desc>
      <ref name="core"/>
    </element>
  </start>

  <define name="core">
    <element name="ns:Core">
      <doc:desc>A description of the server, for example "Acme e-commerce app server"</doc:desc>
      <attribute ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="ID">
        <value>Core</value>
      </attribute>
      <interleave>
        <element name="ns:SystemContainer">
          <doc:desc>The name of the container in which to put system files.  By default "ftss"</doc:desc>
          <text/>
        </element>
        <choice>
          <ref name="postgres-driver"/>
          <ref name="flatfile-driver"/>
          <ref name="metakit-driver"/>
        </choice>
        <ref name="regular-events"/>
        <ref name="local-state"/>
        <ref name="server-control"/>
      </interleave>
    </element>
  </define>

  <define name="postgres-driver">
    <element name="ns:Driver">
      <attribute ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="parseType">
        <value>Resource</value>
      </attribute>
      <interleave>
        <element ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="type">
          <attribute name="resource">
            <value>http://xmlns.4suite.org/4ss/properties#Postgres</value>
          </attribute>
        </element>
        <element name="ns:DbName">
          <doc:desc></doc:desc>
          <text/>
        </element>
        <optional>
          <element name="ns:User">
            <doc:desc></doc:desc>
            <text/>
          </element>
        </optional>
        <optional>
          <element name="ns:Password">
            <doc:desc></doc:desc>
            <text/>
          </element>
        </optional>
        <optional>
          <element name="ns:Host">
            <doc:desc></doc:desc>
            <text/>
          </element>
        </optional>
        <optional>
          <element name="Port">
            <doc:desc></doc:desc>
            <data type="integer"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="flatfile-driver">
    <element name="Driver">
      <attribute ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="parseType">
        <value>Resource</value>
      </attribute>
      <interleave>
        <element ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="type">
          <attribute name="resource">
            <value>http://xmlns.4suite.org/4ss/properties#FlatFile</value>
          </attribute>
        </element>
        <element name="ns:Root">
          <doc:desc></doc:desc>
          <text/>
        </element>
      </interleave>
    </element>
  </define>

  <define name="metakit-driver">
    <element name="Driver">
      <attribute ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="parseType">
        <value>Resource</value>
      </attribute>
      <interleave>
        <element ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" name="type">
          <attribute name="resource">
            <value>http://xmlns.4suite.org/4ss/properties#MetaKit</value>
          </attribute>
        </element>
        <element name="ns:DbName">
          <doc:desc></doc:desc>
          <text/>
        </element>
      </interleave>
    </element>
  </define>

  <define name="regular-events">
    <interleave>
      <optional>
        <element name="ns:XsltStrobeInterval">
          <doc:desc>4Suite allows you to register XSLT files to be executed against the repository root container at a regular interval.  This is the strobe that wakes up the dispatch system for these scripts.</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
      <optional>
        <element name="ns:DynamicReloadInterval">
          <doc:desc>If you change any server configuration files, you have to restart the repository, unless you set the dynamic reload interval, which checks for such server file changes and reloads as appropriate.</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
      <optional>
        <element name="ns:TemporaryReapInterval">
          <doc:desc>This causes the repository to wake up and check for stale temporary files for deletion.  You will want to set this to a non-zero value if you use temporary files in any of your applications.</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="local-state">
    <interleave>
      <element name="ns:PidFile">
        <doc:desc></doc:desc>
        <text/>
      </element>
      <element name="ns:LogFile">
        <doc:desc></doc:desc>
        <text/>
      </element>
      <optional>
        <element name="ns:LogLevel">
          <doc:desc></doc:desc>
          <choice>
            <value>emerg</value>
            <value>crit</value>
            <value>error</value>
            <value>warning</value>
            <value>notice</value>
            <value>info</value>
            <value>debug</value>
          </choice>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="server-control">
    <interleave>
      <optional>
        <element name="ns:StartServers">
          <doc:desc>Number of servers to start, default is 5</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
      <optional>
        <element name="ns:MinSpareServers">
          <doc:desc>Minimum number of idle servers, default is 5</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
      <optional>
        <element name="ns:MaxSpareServers">
          <doc:desc>Maximum number of idle servers, default is 10</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
      <optional>
        <element name="ns:MaxServers">
          <doc:desc>Maximum number of servers ever, default is 150</doc:desc>
          <data type="integer"/>
        </element>
      </optional>
    </interleave>
  </define>

</grammar>

