<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.w3.org/2001/XMLSchema XMLSchema.xsd"
            xmlns:Deployment="http://www.omg.org/Deployment"
            targetNamespace="http://www.omg.org/Deployment">

  <xsd:include schemaLocation="Basic_Deployment_Data.xsd" />
  <xsd:include schemaLocation="ccd.xsd" />
  <xsd:include schemaLocation="iad.xsd" />
  <xsd:include schemaLocation="pcd.xsd" />
  <xsd:include schemaLocation="cpd.xsd" />
  
  <xsd:complexType name="ComponentPackageReference">
    <xsd:sequence>
      <xsd:element name="requiredUUID" type="xsd:string" minOccurs="0" />
      <xsd:element name="requiredName" type="xsd:string" minOccurs="0" />
      <xsd:element name="requiredType" type="Deployment:ComponentInterfaceDescription"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="SubcomponentInstantiationDescription">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="basePackage" type="Deployment:ComponentPackageDescription" minOccurs="0" />
      <xsd:element name="specializedConfig" type="Deployment:PackageConfiguration" minOccurs="0" />
      <xsd:element name="selectRequirement" type="Deployment:Requirement" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="configProperty" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="referencedPackage" type="Deployment:ComponentPackageReference" minOccurs="0"/>
      <xsd:element name="importedPackage" type="Deployment:ComponentPackageImport" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>

  <xsd:complexType name="SubcomponentPropertyReference">
    <xsd:sequence>
      <xsd:element name="propertyName" type="xsd:string"/>
      <xsd:element name="instance" type="Deployment:IdRef"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="AssemblyPropertyMapping">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="externalName" type="xsd:string"/>
      <xsd:element name="delegatesTo" type="Deployment:SubcomponentPropertyReference" minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:simpleType name="LocalityKind">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="SameNodeAnyProcess"/>
      <xsd:enumeration value="SameNodeSameProcess"/>
      <xsd:enumeration value="SameNodeDifferentProcess"/>
      <xsd:enumeration value="DifferentNode"/>
      <xsd:enumeration value="DifferentProcess"/>
      <xsd:enumeration value="NoConstraint"/>
    </xsd:restriction>
  </xsd:simpleType>
  
  <!-- Locality needs to be implemented -->
  <xsd:complexType name="Locality">
    <xsd:sequence>
      <xsd:element name="constraint" type="Deployment:LocalityKind"/>
      <xsd:element name="constrainedInstance" type="Deployment:IdRef"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="ComponentAssemblyDescription">
    <xsd:sequence>
      <xsd:element name="instance" type="Deployment:SubcomponentInstantiationDescription" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="connection" type="Deployment:AssemblyConnectionDescription" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="externalProperty" type="Deployment:AssemblyPropertyMapping" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="locality" type="Deployment:Locality" minOccurs="0" maxOccurs="unbounded" /> <!-- @@todo: needs to be implemented -->
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="MonolithicImplementationDescription">
    <xsd:sequence>
      <xsd:element name="nodeExecParameter" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="componentExecParameter" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="deployRequirement" type="Deployment:ImplementationRequirement" minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="primaryArtifact" type="Deployment:NamedImplementationArtifact" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="ComponentImplementationDescription">
    <xsd:choice minOccurs="0" maxOccurs="1">
      <xsd:sequence>
        <xsd:element name="label" type="xsd:string" minOccurs="0" />
        <xsd:element name="UUID" type="xsd:string" minOccurs="0" />
        <!-- @@ MAJO : Hack: Implements should be required. -->
        <xsd:element name="implements" type="Deployment:ComponentInterfaceDescription" minOccurs="0" />
        <xsd:choice>
          <xsd:element name="assemblyImpl" type="Deployment:ComponentAssemblyDescription"/>
          <xsd:element name="monolithicImpl" type="Deployment:MonolithicImplementationDescription"/>
        </xsd:choice>
        <xsd:element name="configProperty" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="capability" type="Deployment:Capability" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="dependsOn" type="Deployment:ImplementationDependency" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="infoProperty" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
      </xsd:sequence>
    </xsd:choice>
    <xsd:attribute name="href" type="xsd:string" use="optional"/>
  </xsd:complexType>

  <xsd:complexType name="ConnectorImplementationDescription">
    <xsd:choice minOccurs="0" maxOccurs="1">
      <xsd:sequence>
        <xsd:element name="label" type="xsd:string" minOccurs="0" />
        <xsd:element name="UUID" type="xsd:string" minOccurs="0" />
        <!-- @@ MAJO : Hack: Implements should be required. -->
        <xsd:element name="implements" type="Deployment:ComponentInterfaceDescription" minOccurs="0" />
        <xsd:choice>
          <xsd:element name="assemblyImpl" type="Deployment:ComponentAssemblyDescription"/>
          <xsd:element name="monolithicImpl" type="Deployment:MonolithicImplementationDescription"/>
        </xsd:choice>
        <xsd:element name="configProperty" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="capability" type="Deployment:Capability" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="dependsOn" type="Deployment:ImplementationDependency" minOccurs="0" maxOccurs="unbounded" />
        <xsd:element name="infoProperty" type="Deployment:Property" minOccurs="0" maxOccurs="unbounded" />
      </xsd:sequence>
    </xsd:choice>
    <xsd:attribute name="href" type="xsd:string" use="optional"/>
  </xsd:complexType>

</xsd:schema>
