<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
  <ref name="comps"/>
</start>

<define name="package-name">
  <text/>
</define>

<define name="group-name">
  <text/>
</define>

<define name="lang">
  <text/>
</define>

<define name="description-text">
  <text/>
</define>

<define name="comps">
  <element name="comps">
    <oneOrMore>
      <ref name="group"/>
    </oneOrMore>
    <ref name="grouphierarchy"/>
    <oneOrMore>
      <ref name="package"/>
    </oneOrMore>
  </element>
</define>

<define name="group">
  <element name="group">
    <element name="id">
      <ref name="group-name"/>
    </element>
    <interleave>
      <ref name="names"/>
      <optional>
        <element name="default">
          <choice>
            <value>true</value>
            <value>false</value>
          </choice>
        </element>
      </optional>
      <optional>
        <ref name="descriptions"/>
      </optional>
      <optional>
        <element name="uservisible">
          <choice>
            <value>true</value>
            <value>false</value>
          </choice>
        </element>
      </optional>
      <optional>
        <element name="langonly">
	  <ref name="lang"/>
        </element>
      </optional>
    </interleave>
    <optional>
      <element name="grouplist">
        <zeroOrMore>
	  <element name="groupreq">
	    <ref name="group-name"/>
	  </element>
        </zeroOrMore>
        <zeroOrMore>
	  <element name="metapkg">
	    <attribute name="type">
	      <choice>
	        <value>default</value>
	        <!-- <value>mandatory</value> ?? -->
	        <value>optional</value>
	      </choice>
	    </attribute>
	    <ref name="package-name"/>
	  </element>
        </zeroOrMore>
      </element>
    </optional>
    <optional>
      <element name="packagelist">
        <oneOrMore>
          <element name="packagereq">
	    <attribute name="type">
	      <choice>
	        <value>default</value>
	        <value>mandatory</value>
	        <value>optional</value>
	      </choice>
	    </attribute>
	    <optional>
	      <attribute name="requires">
	        <ref name="package-name"/>
	      </attribute>
	    </optional>
	    <ref name="package-name"/>
	  </element>
        </oneOrMore>
      </element>
    </optional>
  </element>
</define>

<define name="grouphierarchy">
  <element name="grouphierarchy">
    <oneOrMore>
      <ref name="category"/>
    </oneOrMore>
  </element>
</define>

<define name="category">
  <element name="category">
    <ref name="names"/>
    <optional>
      <element name="subcategories">
        <oneOrMore>
	  <element name="subcategory">
	    <ref name="package-name"/>
	  </element>
        </oneOrMore>
      </element>
    </optional>
  </element>
</define>

<define name="package">
  <element name="package">
    <element name="name">
      <ref name="package-name"/>
    </element>
    <element name="dependencylist">
      <zeroOrMore>
        <element name="dependency">
	  <ref name="package-name"/>
	</element>
      </zeroOrMore>
    </element>
  </element>
</define>

<define name="names">
  <element name="name">
    <ref name="description-text"/>
  </element>
  <zeroOrMore>
    <element name="name">
      <attribute name="xml:lang">
        <ref name="lang"/>
      </attribute>
      <ref name="description-text"/>
    </element>
  </zeroOrMore>
</define>

<define name="descriptions">
  <element name="description">
    <ref name="description-text"/>
  </element>
  <zeroOrMore>
    <element name="description">
      <attribute name="xml:lang">
        <ref name="lang"/>
      </attribute>
      <ref name="description-text"/>
    </element>
  </zeroOrMore>
</define>

</grammar>
