<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="extension" type="ExtensionType" />

    <xs:complexType name="ExtensionType">
        <xs:sequence>
            <xs:element name="id" type="xs:string" />
            <xs:element name="type" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="parameters" type="ParametersType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="group" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="desc" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="config" type="ConfigType" />
        </xs:sequence>
        <xs:anyAttribute processContents="skip" />
    </xs:complexType>

    <xs:complexType name="ParametersType">
        <xs:sequence>
            <xs:element name="param" type="ParamType" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="ParamType">
        <xs:attribute name='name' type='xs:string' use="required" />
        <xs:attribute name='default' type='xs:string' />
    </xs:complexType>
    
    <xs:complexType name="ConfigType">
        <xs:sequence>
            <xs:element name="object" type="ObjectType" />
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="TypeType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="standard" />
            <xs:enumeration value="template" />
        </xs:restriction>
    </xs:simpleType>

    <!-- Object Type -->
    <xs:complexType name="ObjectType">
        <xs:sequence>
            <xs:element name="serviceList" type="ServiceListType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="service" type="ServiceType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="matrix"  type="xs:string"  minOccurs="0" maxOccurs="1" />
            <xs:element name="value"  type="xs:string"  minOccurs="0" maxOccurs="1" />
            <xs:element name="item"  type="ItemType"  minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="node"  type="NodeType"  minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="edge"  type="EdgeType"  minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="connect"  type="ConnectionType"  minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="proxy"  type="ProxyType"  minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="start" type="StartType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="update" type="UpdateType" minOccurs="0" maxOccurs="unbounded" />
            <!-- <xs:element name="stop" minOccurs="0" maxOccurs="0" /> -->
            <!-- <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> -->
        </xs:sequence>
        <xs:attribute name='uid' type='xs:string' />
        <xs:attribute name='type' type='xs:string'/>
        <xs:attribute name='src' type='xs:string' />
    </xs:complexType>
    
    <!-- Item Type -->
    <xs:complexType name="ItemType">
        <xs:sequence>
             <xs:element name="object" type="ObjectType" minOccurs="1" maxOccurs="1" />
        </xs:sequence>
        <xs:attribute name='key' type='xs:string' />
    </xs:complexType>
    
    <!-- Service Type -->
    <xs:complexType name="ServiceType">
        <xs:sequence>
            <xs:any processContents="skip" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name='uid' type='xs:string' />
        <xs:attribute name='type' type='xs:string' use="optional" />
        <xs:attribute name='impl' type='xs:string' use="required" />
        <xs:attribute name='autoConnect' type='AutoConnectType' />
        <xs:attribute name='worker' type='xs:string' />
    </xs:complexType>

    <!-- Connection Type -->
    <xs:complexType name="ConnectionType">
        <xs:sequence>
            <xs:element name="signal"  type="xs:string"  minOccurs="1" maxOccurs="1" />
            <xs:element name="slot"  type="xs:string"  minOccurs="1" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <!-- Proxy Type -->
    <xs:complexType name="ProxyType">
        <xs:sequence>
            <xs:element name="signal" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="slot" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name='channel' type='xs:string' />
    </xs:complexType>

    <!-- Start/Update/stop Type -->
    <xs:complexType name="StartType">
        <xs:attribute name='uid' type='xs:string' />
        <xs:attribute name='type' type='xs:string' />
    </xs:complexType>
    
    <xs:complexType name="UpdateType">
        <xs:attribute name='uid' type='xs:string' />
        <xs:attribute name='type' type='xs:string' />
    </xs:complexType>
        
    <xs:simpleType name="AutoConnectType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="yes" />
            <xs:enumeration value="no" />
        </xs:restriction>
    </xs:simpleType>
    
    <!-- ServiceList Type -->
    <xs:complexType name="ServiceListType">
        <xs:sequence>
            <xs:element name="service" type="ServiceType" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <!-- NodeType Type -->
    <xs:complexType name="NodeType"> <!-- Almost the same as ObjectType -->
        <xs:sequence>
            <xs:element name="object" type="ObjectType" minOccurs="0" maxOccurs="1" />
            <xs:element name="serviceList" type="ServiceListType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="service" type="ServiceType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="start" type="StartType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="update" type="UpdateType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="uid" type="xs:string" use="required" />
        <xs:attribute name="src" type="xs:string" />
    </xs:complexType>

    <!-- EdgeType Type -->
    <xs:complexType name="EdgeType"> <!-- Same as NodeType, but with optionnal "weight" attribute -->
        <xs:sequence>
            <xs:element name="object" type="ObjectType" minOccurs="0" maxOccurs="1" />
            <xs:element name="serviceList" type="ServiceListType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="service" type="ServiceType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="start" type="StartType" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="update" type="UpdateType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="origin" type="xs:string" use="required" />
        <xs:attribute name="target" type="xs:string" use="required" />
        <xs:attribute name="weight" type="xs:string" />
        <xs:attribute name="uid" type="xs:string" />
        <xs:attribute name="src" type="xs:string" />
    </xs:complexType>

</xs:schema>        
