<?xml version="1.0" encoding="utf-8" ?>

<!--
  Copyright (c) 1997-2010
  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
  http://www.polymake.de

  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 2, or (at your option) any
  later version: http://www.gnu.org/licenses/gpl.txt.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
===============================================================================
  $Project: polymake $$Id: docfile.rng 9545 2010-03-09 00:34:42Z gawrilow $

  Relax-NG Schema for polymake v3 automatic documentation file
-->

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
         ns="http://www.polymake.de/ns/docs#3">

  <start>
    <ref name="Application" />
  </start>

  <define name="Application">
    <element name="application">
      <ref name="NameAttr" />
      <ref name="Description" />

      <optional>
        <element name="imports-from">
          <ref name="AppList" />
        </element>
      </optional>

      <optional>
        <element name="uses">
          <ref name="AppList" />
        </element>
      </optional>

      <optional>
        <element name="property-types">
          <oneOrMore>
            <element name="type">
              <ref name="NameAttr" />
              <ref name="Id" />
              <ref name="Description" />

              <optional>
                <element name="derived-from">
                  <attribute name="type" />
                  <attribute name="href" />
                </element>
              </optional>

              <optional>
                <ref name="UserMethods" />
              </optional>
            </element>
          </oneOrMore>
        </element>
      </optional>

      <optional>
        <ref name="Objects" />
      </optional>

      <optional>
        <element name="user-functions">
          <ref name="FuncList" />
        </element>
      </optional>

    </element>
  </define>

  <define name="AppList">
    <oneOrMore>
      <element name="application">
        <ref name="NameAttr" />
      </element>
    </oneOrMore>
  </define>

  <define name="UserMethods">
    <element name="user-methods">
      <ref name="FuncList" />
    </element>
  </define>

  <define name="FuncList">
    <zeroOrMore>
      <element name="category">
        <attribute name="name" />
        <optional>
          <ref name="Description" />
        </optional>
        <oneOrMore>
          <ref name="Function" />
        </oneOrMore>
      </element>
    </zeroOrMore>
    <zeroOrMore>
      <ref name="Function" />
    </zeroOrMore>
  </define>

  <define name="Function">
    <element name="function">
      <ref name="NameAttr" />
      <ref name="Id" />
      <zeroOrMore>
        <element name="tparam">
          <ref name="NameAttr" />
	  <ref name="Description" />
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <element name="param">
          <ref name="NameAttr" />
	  <attribute name="type" />
          <attribute name="href" />
          <optional>
            <ref name="Description" />
          </optional>
        </element>
      </zeroOrMore>
      <choice>
        <zeroOrMore>
          <ref name="Option" />
        </zeroOrMore>
        <zeroOrMore>
          <element name="options">
            <ref name="Description" />
            <oneOrMore>
              <ref name="Option" />
            </oneOrMore>
        </zeroOrMore>
      </choice>
      <optional>
        <element name="return">
          <attribute name="type" />
          <attribute name="href" />
          <optional>
	    <ref name="Description" />
          </optional>
        </element>
      </optional>
      <optional>
        <ref name="Description" />
      </optional>
    </element>
  </define>

  <define name="Properties">
    <element name="properties">
      <zeroOrMore>
        <element name="category">
          <attribute name="name" />
          <optional>
            <ref name="Description" />
          </optional>
          <oneOrMore>
            <ref name="Property" />
          </oneOrMore>
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="Property" />
      </zeroOrMore>
    </element>
  </define>

  <define name="Permutations">
    <element name="permutations">
      <zeroOrMore>
        <element name="permutation">
          <ref name="NameAttr" />
          <ref name="Id" />
          <ref name="Description" />

          <optional>
            <ref name="Properties" />
          </optional>
          <optional>
            <ref name="UserMethods" />
          </optional>
        </element>
      </zeroOrMore>
    </element>
  </define>

  <define name="Property">
    <element name="property">
      <ref name="NameAttr" />
      <ref name="Id" />
      <attribute name="type" />
      <attribute name="href" />
      <ref name="Description" />

      <optional>
        <ref name="Properties" />
      </optional>
      <optional>
        <ref name="UserMethods" />
      </optional>
    </element>
  </define>

  <define name="Objects">
    <element name="objects">
      <zeroOrMore>
        <element name="category">
          <attribute name="name" />
          <optional>
            <ref name="Description" />
          </optional>
          <oneOrMore>
            <ref name="Object" />
          </oneOrMore>
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="Object" />
      </zeroOrMore>
    </element>
  </define>

  <define name="Object">
    <element name="object">
      <attribute name="name" />
      <ref name="Id" />
      <optional>
        <ref name="Description" />
      </optional>

      <zeroOrMore>
        <element name="derived-from">
          <attribute name="object" />
          <attribute name="href" />
        </element>
      </zeroOrMore>

      <optional>
        <ref name="Properties" />
      </optional>
      <optional>
        <ref name="Permutations" />
      </optional>
      <optional>
	<ref name="UserMethods" />
      </optional>
    </element>
  </define>

  <define name="Id">
    <attribute name="xml:id">
      <data type="ID" />
    </attribute>
  </define>

  <define name="Option">
    <element name="option">
      <attribute name="name" />
      <attribute name="type" />
      <attribute name="href" />
      <optional>
        <ref name="Description" />
      </optional>
    </element>
  </define>

  <define name="NameAttr">
    <attribute name="name">
      <data type="string">
        <param name="pattern">[a-zA-Z][a-zA-Z_0-9]*</param>
      </data>
    </attribute>
  </define>

  <define name="Description">
    <element name="description">
      <ref name="HTML" />
    </element>
  </define>

  <define name="HTML">
    <oneOrMore>
      <choice>
        <text/>
        <ref name="HTMLelement"/>
      </choice>
    </oneOrMore>
  </define>

  <define name="HTMLelement">
    <element>
      <nsName ns="http://www.w3.org/1999/xhtml" />
      <zeroOrMore>
        <attribute>
	  <anyName/>
	</attribute>
      </zeroOrMore>
      <ref name="HTML"/>
    </element>
  </define>

</grammar>
