<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:tns="http://jboss.org/schema/arquillian" xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://jboss.org/schema/arquillian" version="1.0">

    <element name="arquillian">
        <complexType>
            <sequence>
                <element ref="tns:defaultProtocol" minOccurs="0" maxOccurs="1" />
                <element ref="tns:engine" minOccurs="0" maxOccurs="1" />
                <choice minOccurs="1" maxOccurs="unbounded">
                    <element ref="tns:container" minOccurs="0" maxOccurs="unbounded" />
                    <element ref="tns:group" minOccurs="0" maxOccurs="unbounded" />
                    <element ref="tns:extension" minOccurs="0" maxOccurs="unbounded" />
                </choice>
            </sequence>
        </complexType>

        <unique name="unique-qualifier-between-container-and-group">
            <annotation>
                <documentation>
                    @qualifier must be unique between containers and groups. 
                    Used to select which to run.
                </documentation>
            </annotation>
            <selector xpath="tns:container|tns:group" />
            <field xpath="@qualifier" />
        </unique>
        <unique name="unique-qualifier-between-extensions">
            <annotation>
                <documentation>
                    @qualifier must be unique between
                    extensions. Used to select which to run.
                </documentation>
            </annotation>
            <selector xpath="tns:extension" />
            <field xpath="@qualifier" />
        </unique>
    </element>

    <element name="engine">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:property" />
            </choice>
        </complexType>
        <unique name="unique-property-within-engine">
            <annotation>
                <documentation>
                    Property must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:property" />
            <field xpath="@name" />
        </unique>
    </element>

    <element name="group">
        <annotation>
            <documentation>
                You can run tests against multiple containers in the same run. To do
                this you define them as a group. All
                containers in the group will be started during the run.
            </documentation>
        </annotation>
        <complexType>
            <choice>
                <element ref="tns:container" minOccurs="1" maxOccurs="unbounded" />
            </choice>
            <attribute name="qualifier" type="string" use="required" />
            <attribute name="default" type="boolean" use="optional" default="false" />
        </complexType>
        <unique name="unique-qualifier-of-containers-within-group">
            <annotation>
                <documentation>
                    @qualifier must be unique between all
                    containers in a group. Used to select which to
                    target.
                </documentation>
            </annotation>
            <selector xpath="tns:container" />
            <field xpath="@qualifier" />
        </unique>
    </element>

    <element name="container">
        <complexType>
            <choice minOccurs="1" maxOccurs="unbounded">
                <element ref="tns:configuration" minOccurs="0"  maxOccurs="1" />
                <!--
                <element ref="tns:dependencies" minOccurs="0" maxOccurs="1" />
                -->
                <element ref="tns:protocol" minOccurs="0" maxOccurs="unbounded" />
            </choice>
            <attribute name="qualifier" type="string" use="required" />
            <attribute name="default" type="boolean" use="optional" default="false" />
            <attribute name="mode" use="optional" default="suite">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="suite" />
                        <enumeration value="class" />
                        <enumeration value="manual" />
                        <enumeration value="custom" />
                    </restriction>
                </simpleType>
            </attribute>
        </complexType>
        <unique name="unique-protocol-within-container">
            <annotation>
                <documentation>
                    @type must be unique between all
                    protocols in a container.
                </documentation>
            </annotation>
            <selector xpath="tns:protocol" />
            <field xpath="@type" />
        </unique>
    </element>

    <element name="extension">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:property" />
            </choice>
            <attribute name="qualifier" type="string" use="required" />
        </complexType>
        <unique name="unique-property-within-extension">
            <annotation>
                <documentation>
                    Property must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:property" />
            <field xpath="@name" />
        </unique>
    </element>

    <element name="defaultProtocol">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:property" />
            </choice>
            <attribute name="type" type="string" use="required" />
        </complexType>
        <unique name="unique-property-within-protocol">
            <annotation>
                <documentation>
                    Property must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:property" />
            <field xpath="@name" />
        </unique>
    </element>

    <element name="protocol">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:property" />
            </choice>
            <attribute name="type" type="string" use="required" />
        </complexType>
        <unique name="unique-property-within-default-protocol">
            <annotation>
                <documentation>
                    Property must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:property" />
            <field xpath="@name" />
        </unique>
    </element>

    <element name="configuration">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:property" minOccurs="1" maxOccurs="unbounded" />
            </choice>
        </complexType>
        <unique name="unique-property-within-configuration">
            <annotation>
                <documentation>
                    Property must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:property" />
            <field xpath="@name" />
        </unique>
    </element>

<!--
    <element name="dependencies">
        <complexType>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="tns:dependency" />
            </choice>
        </complexType>
        <unique name="unique-dependency-within-container">
            <annotation>
                <documentation>
                    Dependencies must be unique.
                </documentation>
            </annotation>
            <selector xpath="tns:dependency" />
            <field xpath="." />
        </unique>
    </element>
    <element name="dependency">
        <complexType>
            <simpleContent>
                <extension base="string" />
            </simpleContent>
        </complexType>
    </element>
-->

    <element name="property">
        <complexType>
            <simpleContent>
                <extension base="string">
                    <attribute name="name" type="string" use="required" />
                </extension>
            </simpleContent>
        </complexType>
    </element>

</schema>
