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

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="install">
      <ref name="serial-number"/>
      <ref name="partitions"/>
      <optional>
	<ref name="raids"/>
      </optional>
      <ref name="mount-points"/>
      <ref name="network"/>
      <ref name="groups"/>
      <optional>
	<ref name="services"/>
      </optional>
    </element>
  </start>

  <define name="serial-number">
    <element name="serial-number">
      <text/>
    </element>
  </define>

  <define name="partitions">
    <element name='partitions'>
      <attribute name='unit'/>
	<choice>
	  <value>msdos</value>
	  <value>gpt</value>
	</choice>
      </attribute>
      <oneOrMore>
	<element name='partition'>
	  <attribute name='device'/>
	  <attribute name='start'/>
	  <attribute name='size'/>
	  <attribute name='from_os'>
	    <ref name='mybool'/>
	  </attribute>
		<attribute name='file-system'/>
	  <attribute name='flags'/>
	  <attribute name='type'/>
	</element>
      </oneOrMore>
    </element>
  </define>

  <define name="raids">
    <element name='raids'>
      <oneOrMore>
	<element name="raid">
	  <attribute name="device"/>
	  <attribute name="level">
	    <choice>
	      <value>0</value>
	      <value>1</value>
	      <value>5</value>
	    </choice>
	  </attribute>
	  <attribute name="from_os">
	    <ref name='mybool'/>
	  </attribute>
	  <element name='active'>
	    <ref name='raid_components'/>
	  </element>
	  <optional>
	    <element name='spare'>
	      <ref name='raid_components'/>
	    </element>
	  </optional>
	</element>
      </oneOrMore>
    </element>
  </define>

  <define name='raid_components'>
    <oneOrMore>
      <element name="component">
	<text/>
      </element>
    </oneOrMore>
  </define>

  <define name="mount-points">
    <element name="mount-points">
      <oneOrMore>
	<element name="mount-point">
	  <attribute name="device"/>
	  <attribute name="directory"/>
	  <attribute name="file-system"/>
	  <attribute name="format">
	    <ref name="mybool"/>
	  </attribute>
	</element>
      </oneOrMore>
    </element>
  </define>

  <define name="network">
    <element name="network">
      <attribute name="hostname"/>
      <attribute name="configuration">
	<choice>
	  <value>dynamic</value>
	  <value>static</value>
	</choice>
      </attribute>
      <optional>
	<group>
	  <attribute name="ip"/>
	  <attribute name="mask"/>
	  <attribute name="gateway"/>
	  <attribute name="primary_dns"/>
	  <attribute name="secondary_dns"/>
	  <attribute name="domain"/>
	</group>
      </optional>
    </element>
  </define>

  <define name="groups">
    <element name='groups'>
      <oneOrMore>
	<element name="group">
	  <attribute name="name"/>
	  <attribute name="install">
	    <choice>
	      <value>mandatory</value>
	      <value>yes</value>
	      <value>no</value>
	    </choice>
	  </attribute>
	  <optional>
	    <ref name="description"/>
	  </optional>
	  <optional>
	    <element name='mandatory'>
	      <ref name='packages'/>
	    </element>
	  </optional>
	  <optional>
	    <element name='optional'>
	      <attribute name='selection'>
		<choice>
		  <value>all</value>
		  <value>none</value>
		  <value>manual</value>
		</choice>
	      </attribute>
	      <ref name='packages'/>
	    </element>
	  </optional>
	</element>
      </oneOrMore>
    </element>
  </define>

  <define name="description">
    <element name="description">
      <text/>
    </element>
  </define>
  
  <define name="packages">
    <oneOrMore>
      <element name="package">
	<attribute name="name"/>
	<optional>
	  <attribute name="install">
	    <ref name="mybool"/>
	  </attribute>
	</optional>
      </element>
    </oneOrMore>
  </define>

  <define name="mybool">
    <choice>
      <value>yes</value>
      <value>no</value>
    </choice>
  </define>

  <define name='services'>
    <element name='services'>
      <zeroOrMore>
	<element name='service'>
	  <attribute name='name'/>
	  <attribute name='number'/>
	  <attribute name='script'/>
	  <attribute name='start'>
	    <choice>
	      <value>disable</value>
	      <value>yes</value>
	      <value>no</value>
	    </choice>
	  </attribute>
	  <attribute name='package'/>
	</element>
      </zeroOrMore>
    </element>
  </define>

</grammar>
