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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://camitk.imag.fr/3/asm"
            xmlns:camitk="http://camitk.imag.fr/3/asm"
            elementFormDefault="qualified">

    <xsd:attributeGroup name="scxmlCamitkAttributes">
        <xsd:attribute name="applicationName" type="xsd:string" use="required"/>
        <xsd:attribute name="saveDirectory" type="xsd:anyURI" use="optional"/>
    </xsd:attributeGroup>

    <xsd:attributeGroup name="transitionCamitkAttributes">
        <xsd:attribute name="applyAction" type="xsd:boolean" use="optional" default="true"/>
        <xsd:attribute name="disable" type="camitk:PreviousStatus"/>
    </xsd:attributeGroup>

    <xsd:complexType name="Description" mixed="true"/>
    <xsd:complexType name="AltDescription" mixed="true">
        <xsd:attribute name="previousStatus" type="camitk:PreviousStatus"/>
    </xsd:complexType>

    <xsd:element name="onState" type="camitk:StateDef"/>
    <xsd:complexType name="StateDef">
        <xsd:sequence>
            <xsd:element name="description" type="camitk:Description"/>
            <xsd:element name="altDescription" type="camitk:AltDescription" minOccurs="0"/>
            <xsd:element name="action" type="camitk:Action" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Action">
        <xsd:sequence>
            <xsd:element name="name"        type="xsd:string"/>
            <xsd:element name="parameters"  type="camitk:Parameters" minOccurs="0"/>
            <xsd:element name="inputs"      type="camitk:IOComponents" minOccurs="0"/>
            <xsd:element name="outputs"     type="camitk:IOComponents" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Parameters">
        <xsd:sequence>
            <xsd:element name="parameter" type="camitk:Parameter" minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Parameter">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="camitk:ParameterType" use="required"/>
        <xsd:attribute name="value" type="xsd:string"/>
    </xsd:complexType>

    <xsd:complexType name="IOComponents">
        <xsd:sequence>
            <xsd:element name="component" type="camitk:Component" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Component">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
        <!-- The suffix is optional as it does not concern all the actions.
          -  However, it is MANDATORY for the Save action.
         -->
        <xsd:attribute name="suffix" type="xsd:string" use="optional"/>
        <xsd:attribute name="saveDirectory" type="xsd:anyURI" use="optional"/>
        <!-- force is optional as it does only concern the camitk:close
          -  transition type. If set to true, the camitk:close transition
          -  closes the component without asking the user for a filename even if
          -  the component has been modified
              -->
        <xsd:attribute name="force" type="xsd:boolean" use="optional"/>
    </xsd:complexType>

    <xsd:simpleType name="ParameterType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="int"/>
            <xsd:enumeration value="bool"/>
            <xsd:enumeration value="double"/>
            <xsd:enumeration value="QString"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="PreviousStatus">
        <xsd:list itemType="camitk:Status"/>
    </xsd:simpleType>

    <xsd:simpleType name="Status">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="SUCCESS"/>
            <xsd:enumeration value="ERROR"/>
            <xsd:enumeration value="WARNING"/>
            <xsd:enumeration value="ABORTED"/>
            <xsd:enumeration value="TRIGGERED"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:complexType name="LogFileName">
        <xsd:attribute name="pattern" type="xsd:anyURI"/>
    </xsd:complexType>
    
    <xsd:element name="onTransition" type="camitk:OnTransition"/>    
    <xsd:complexType name="OnTransition">
        <xsd:sequence>
            <xsd:element name="close" type="camitk:IOComponents" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    
</xsd:schema>
