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

<!-- This file contains the XML Schema Document (XSD) for the XML Domains
     Representation defined by the OMG specification "DDS Consolidated XML
     Syntax" (DDS-XML). -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">

    <!-- ================================================================== -->
    <!-- Inclusion of other Building Blocks -->
    <!-- ================================================================== -->

    <xs:include schemaLocation="https://www.omg.org/spec/DDS-XML/20260301/dds-xml_type_definitions_nonamespace.xsd" />
    <xs:include schemaLocation="https://www.omg.org/spec/DDS-XML/20260301/dds-xml_qos_definitions_nonamespace.xsd" />


    <!-- ================================================================== -->
    <!-- Domain Definition -->
    <!-- ================================================================== -->

    <!-- Register Type -->

    <xs:complexType name="registerType">
        <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element name="registered_name" type="identifierName" />
        </xs:choice>

        <xs:attribute name="name" type="elementName" use="required" />
        <xs:attribute name="type_ref" type="elementNameReference"
                      use="optional" />
        <xs:attribute name="format" type="xs:string" use="optional" />
    </xs:complexType>

    <xs:complexType name="registerInterface">
        <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element name="registered_name" type="identifierName" />
        </xs:choice>

        <xs:attribute name="name" type="elementName" use="required" />
        <xs:attribute name="interface_ref" type="elementNameReference"
                      use="optional" />
        <xs:attribute name="format" type="xs:string" use="optional" />
    </xs:complexType>

    <!-- Topic -->

    <xs:complexType name="topic">
        <xs:all>
            <xs:element name="topic_name"      type="topicOrServiceName"  minOccurs="0" />
            <xs:element name="topic_qos"       type="topicQosInline"      minOccurs="0" />
            <xs:element name="datawriter_qos"  type="datawriterQosInline" minOccurs="0" />
            <xs:element name="datareader_qos"  type="datareaderQosInline" minOccurs="0" />
        </xs:all>

        <xs:attribute name="name" type="elementName" use="required" />
        <xs:attribute name="register_type_ref" type="elementNameReference"
                      use="required" />
    </xs:complexType>

    <!-- RPC Services -->
    <xs:complexType name="requesterOrClientConfig">
        <xs:all>
            <xs:element name="request_datawriter_qos" type="datawriterQosInline" minOccurs="0" />
            <xs:element name="reply_datareader_qos" type="datareaderQosInline" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="serverOrReplierConfig">
        <xs:all>
            <xs:element name="request_datareader_qos" type="datareaderQosInline" minOccurs="0" />
            <xs:element name="reply_datawriter_qos" type="datawriterQosInline" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="commonServiceDefn">
        <xs:all>
            <xs:element name="service_name"           type="topicOrServiceName"   minOccurs="0" />
            <xs:element name="request_topic_name"     type="topicOrServiceName"   minOccurs="0" />
            <xs:element name="reply_topic_name"       type="topicOrServiceName"   minOccurs="0" />
            <xs:element name="request_datawriter_qos" type="datawriterQosInline"  minOccurs="0" />
            <xs:element name="request_datareader_qos" type="datareaderQosInline"  minOccurs="0" />
            <xs:element name="reply_datawriter_qos"   type="datawriterQosInline"  minOccurs="0" />
            <xs:element name="reply_datareader_qos"   type="datareaderQosInline"  minOccurs="0" />
         </xs:all>
    </xs:complexType>

    <xs:complexType name="rpcService">
        <xs:complexContent>
            <xs:extension base="commonServiceDefn">
                <xs:attribute name="name" type="elementName" use="required" />
                <xs:attribute name="register_interface_ref" type="elementNameReference"
                            use="required" />            
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="requestReplyService">
        <xs:complexContent>
            <xs:extension base="commonServiceDefn">
                <xs:attribute name="name" type="elementName" use="required" />
                <xs:attribute name="register_request_type_ref" type="elementNameReference"
                            use="required" />
                <xs:attribute name="register_reply_type_ref"   type="elementNameReference"
                            use="required" />          
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Interface Block -->
    <xs:simpleType name="bindingRequirementKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="MANDATORY"/>
            <xs:enumeration value="OPTIONAL"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="interactionServiceRef">
        <xs:attribute name="service_ref" type="elementNameReference"
                      use="required" />
        <xs:attribute name="binding" type="bindingRequirementKind" default="MANDATORY"
                      use="optional" />
    </xs:complexType>

    <xs:complexType name="interactionTopicRef">
        <xs:attribute name="topic_ref" type="elementNameReference"
                      use="required" />
        <xs:attribute name="binding" type="bindingRequirementKind" default="MANDATORY"
                      use="optional" />
    </xs:complexType>

    <xs:complexType name="interactionRole">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="provides_service" type="interactionServiceRef" />
            <xs:element name="requires_service" type="interactionServiceRef" />
            <xs:element name="publishes_topic"  type="interactionTopicRef" />
            <xs:element name="subscribes_topic" type="interactionTopicRef" />
        </xs:choice>

        <xs:attribute name="name" type="elementName" use="required" />
        <xs:attribute name="base_name" type="elementNameReference"/>
    </xs:complexType>   
        
    <!-- Domain -->
    <xs:complexType name="domain">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="register_type"         type="registerType" />
            <xs:element name="register_interface"    type="registerInterface" />
            <xs:element name="topic"                 type="topic" />
            <xs:element name="rpc_service"           type="rpcService" />
            <xs:element name="request_reply_service" type="requestReplyService" />
            <xs:element name="interaction_role"      type="interactionRole" />
        </xs:choice>

        <xs:attribute name="name"       type="elementName" use="required" />
        <xs:attribute name="base_name"  type="elementNameReference"/>
        <xs:attribute name="domain_id"  type="xs:nonNegativeInteger" />
        <xs:attribute name="domain_tag" type="domainTagName"/>
    </xs:complexType>


    <!-- ================================================================== -->
    <!-- Domain Library Definitions -->
    <!-- ================================================================== -->

    <xs:complexType name="domainLibrary">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="domain" type="domain" />
        </xs:choice>

        <xs:attribute name="name" type="elementName" use="required" />
    </xs:complexType>

</xs:schema>
