<?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"
  ns="http://xmlns.4suite.org/reserved"
>

  <start>
    <element name="Server" ns="http://xmlns.4suite.org/reserved">
      <doc:desc>A Server definition, which sets various parameters for the behavior of a particular network
				server, including the protocol and port used, the interpretation of requests.  The most common servers
				defined by 4Suite are HTTP servers.  For HTTP servers, this properties file allows the developer to specify
				redirects, URL interpretation rules and the like.
      </doc:desc>
      <interleave>
        <ref name="prologue"/>
        <choice>
          <ref name="http-specs"/>
          <ref name="ftp-specs"/>
        </choice>
      </interleave>
    </element>
  </start>

  <define name="prologue">
    <interleave>
      <optional>
      <element name="description" ns="http://purl.org/dc/elements/1.1/">
        <doc:desc>A description of the server, for example "Acme e-commerce app server"</doc:desc>
        <text/>
      </element>
      </optional>
      <element name="Module">
        <doc:desc>The 4Suite implementation server to use.  This basically defines the server protocol.
 Other values than the ones enumerated are allowed, as long as corresponding Python modules exist.  If
					so, you may ned to pudate this grammar</doc:desc>
        <!-- FIXME: just figure out a good way to make the grammar accept all options.  Maybe schematron
				rule with a special extension function? -->
        <choice>
          <value>Http</value>
          <value>Ftp</value>
          <value>FtRpc</value>
        </choice>
      </element>
      <element name="Handler">
        <doc:desc>The 4Suite handler class tag to use within the given module.  The actual mapping from
					class tag to Python handler class object is given in a "handlers" dictionary in the given module.</doc:desc>
        <!-- FIXME: just figure out a good way to make the grammar accept all options.  Maybe schematron
				rule with a special extension function? -->
        <choice>
          <value>http_basic</value>
          <value>ftp</value>
          <value>ftrpc</value>
        </choice>
      </element>
      <element name="Port">
        <doc:desc>The network port number on which this server will listen</doc:desc>
        <data type="integer"/>
      </element>
      <optional>
      <element name="ServerName">
        <doc:desc>Name of the server, to be used in certain error and status messages</doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="ServerAdmin">
        <doc:desc>e-mail address of the server admin, to be displayed in certain error and status messages</doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="LogLevel">
        <doc:desc>Specifies how verbose the logging messages should be.  From "emerg" (log emergencies
					only) through "debug" (log the whole kittin kaboodle)</doc:desc>
        <choice>
          <value>debug</value>
          <value>info</value>
          <value>notice</value>
          <value>warn</value>
          <value>error</value>
          <value>crit</value>
          <value>alert</value>
          <value>emerg</value>
        </choice>
      </element>
      </optional>
      <optional>
      <element name="Status">
        <doc:desc>A dynamic and internal property stating whether or not the server is currently running.
 There is no need to specify this in template server specifications.</doc:desc>
        <attribute name="running">
          <data type="integer"/>
        </attribute>
      </element>
      </optional>
    </interleave>
  </define>

  <define name="http-specs">
    <interleave>
      <optional>
      <element name="DocumentRoot">
        <doc:desc>The repository path which will be considered the root of the repository (the DocumentRoot).
 Most resource requests on this server will be rooted on this path.</doc:desc>
        <data type="anyURI"/>
      </element>
      </optional>
      <zeroOrMore>
      <element name="Rule">
        <doc:desc>
Rules allow one to specify rewurest URL regular expression that are
interpreted as special instructions to apply stylesheets to return a
dynamic result.  This can be used to implement REST-like design patterns
in the server.

If there are multiple rules, later ones override earlier ones, meaning that if the same pattern can match more than one rule, it will match the one that occurs later on in the server configuration file.
        </doc:desc>
        <attribute name="pattern">
          <doc:desc>
The regular expression to be matched against incoming request URLs.
Named groups are converted into XSLT top-level parameters for the
specified stylesheets.
          </doc:desc>
          <text/>
        </attribute>
        <attribute name="xslt-source">
          <doc:desc>
The repository path of the source document to be used for the XSLT transform.
If omitted or the empty string, the request URL determines the source document.  It is best to make this an absolute repo path.
          </doc:desc>
          <data type="anyURI"/>
        </attribute>
        <attribute name="xslt-transform">
          <doc:desc>
The repository path of the stylesheet resource to use in the transform.
If this is a relative path, it is resolved relative to the source document
path.  Multiple transforms can be specified, separated by spaces.  The
interpretation of these depends on the chain-multiple-transforms attribute.
          </doc:desc>
          <data type="NMTOKENS"/>
        </attribute>
        <attribute name="chain-multiple-transforms">
          <doc:desc>
If multiple transforms are specified, this attribute determines how they
are processed.  If "yes" (the default), they are chained, i.e. the output of one is
fed as the input of the next.  If "no", they are treated as multiple
stylesheets in a single processing step.
          </doc:desc>
          <choice>
            <value>yes</value>
            <value>no</value>
          </choice>
        </attribute>
      </element>
      </zeroOrMore>
      <zeroOrMore>
      <element name="Redirect">
        <doc:desc>Specify a redirect from one repository path to another, which is actually processed
					for the server response</doc:desc>
        <attribute name=
					"src">
          <doc:desc>The repository path which is redirected if patched.  A resource with this path must
						exist in the repository.</doc:desc>
          <data type="anyURI"/>
        </attribute>
        <doc:desc>The resulting URL (just the path and query part of the URL) which is used to provide
					the actual response.  This can be an XSLT invokation, e.g. "/spam/?xslt=eggs.xsl"</doc:desc>
        <data type="anyURI"/>
      </element>
      </zeroOrMore>
      <zeroOrMore>
      <element name="DefaultXslt">
        <doc:desc>Set a default XSLT script to be applied to the contents of a class of resources if directly
					requested</doc:desc>
        <attribute name=
					"type">
          <doc:desc>The resource type.</doc:desc>
          <choice>
            <value>#container</value>
            <value>#group</value>
            <value>#user</value>
            <value>#rawfile</value>
            <value>#group</value>
            <value>#user</value>
            <value>#urireferencefile</value>
            <value>#xmldocument</value>
            <value>#xpathdocumentdefinition</value>
            <value>#xsltdocumentdefinition</value>
            <value>#xsltdocument</value>
            <value>#schematrondocument</value>
            <value>#rdfdocument</value>
            <value>#documentdefinition</value>
            <value>#command</value>
            <value>#server</value>
            <value>#alias</value>
            <value>#meta_data</value>
          </choice>
        </attribute>
        <doc:desc>The repository path for the stylesheet to use to render the given type of objects.</doc:desc>
        <data type="anyURI"/>
      </element>
      </zeroOrMore>
      <optional>
      <element name="SessionMethod">
        <doc:desc>Set the method used to manage session persistence</doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="HttpPostEncodingVar">
        <doc:desc>A variable which is looked for in HTTP form data to specify the encoding to be used
					for parsing the form data.</doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionUserName">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionPassword">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionAnonymousFlag">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionLoginUri">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionInvalidUri">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
      <optional>
      <element name="SessionInvalidLoginUri">
        <doc:desc></doc:desc>
        <text/>
      </element>
      </optional>
    </interleave>
  </define>

  <define name="ftp-specs">
    <interleave>
      <optional>
      <element name="DocumentRoot">
        <doc:desc>The repository path which will be considered the root of the repository (the DocumentRoot).
 Most resource requests on this server will be rooted on this path.</doc:desc>
        <data type="anyURI"/>
      </element>
      </optional>
    </interleave>
  </define>

<!--
      <element name="">
        <doc:desc></doc:desc>
        <text/>
      </element>
	-->
</grammar>

