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

<!-- This file contains the XML Schema Document (XSD) for the XML QoS
     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">

    <!-- ================================================================== -->
    <!-- Definition of simple types                                                         -->
    <!-- ================================================================== -->

    <xs:simpleType name="elementName">
        <xs:restriction base="xs:string">
            <xs:pattern value="((::)?[a-zA-Z0-9_.])+" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="elementNameReference">
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="collapse" />
            <xs:pattern value="((::)?[a-zA-Z0-9_.])+" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="topicNameFilter">
        <xs:restriction base="xs:string">
            <xs:pattern value="([a-zA-Z0-9/*_.:])+" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="destinationOrderKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS" />
            <xs:enumeration value="BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="durabilityKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="VOLATILE_DURABILITY_QOS" />
            <xs:enumeration value="TRANSIENT_LOCAL_DURABILITY_QOS" />
            <xs:enumeration value="TRANSIENT_DURABILITY_QOS" />
            <xs:enumeration value="PERSISTENT_DURABILITY_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="historyKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="KEEP_LAST_HISTORY_QOS" />
            <xs:enumeration value="KEEP_ALL_HISTORY_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="livelinessKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="AUTOMATIC_LIVELINESS_QOS" />
            <xs:enumeration value="MANUAL_BY_PARTICIPANT_LIVELINESS_QOS" />
            <xs:enumeration value="MANUAL_BY_TOPIC_LIVELINESS_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="presentationAccessScopeKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="INSTANCE_PRESENTATION_QOS" />
            <xs:enumeration value="TOPIC_PRESENTATION_QOS" />
            <xs:enumeration value="GROUP_PRESENTATION_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="reliabilityKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="BEST_EFFORT_RELIABILITY_QOS" />
            <xs:enumeration value="RELIABLE_RELIABILITY_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="ownershipKind">
        <xs:restriction base="xs:string">
            <xs:enumeration value="SHARED_OWNERSHIP_QOS" />
            <xs:enumeration value="EXCLUSIVE_OWNERSHIP_QOS" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="nonNegativeInteger_UNLIMITED">
        <xs:restriction base="xs:string">
            <xs:pattern value="(LENGTH_UNLIMITED|([0-9])*)?"></xs:pattern>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="nonNegativeInteger_Duration_SEC">
        <xs:restriction base="xs:string">
            <xs:pattern value="(DURATION_INFINITY|DURATION_INFINITE_SEC|([0-9])*)?" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="nonNegativeInteger_Duration_NSEC">
        <xs:restriction base="xs:string">
            <xs:pattern value="(DURATION_INFINITY|DURATION_INFINITE_NSEC|([0-9])*)?" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="positiveInteger_UNLIMITED">
        <xs:restriction base="xs:string">
            <xs:pattern value="(LENGTH_UNLIMITED|[1-9]([0-9])*)?" />
        </xs:restriction>
    </xs:simpleType>

    <!-- ================================================================== -->
    <!-- Definition of named types -->
    <!-- ================================================================== -->

    <xs:complexType name="duration">
        <xs:all>
            <xs:element name="sec" type="nonNegativeInteger_Duration_SEC"
                minOccurs="0" />
            <xs:element name="nanosec" type="nonNegativeInteger_Duration_NSEC"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="stringSeq">
        <xs:sequence>
            <xs:element name="element" type="xs:string" minOccurs="0"
                maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="deadlineQosPolicy">
        <xs:all>
            <xs:element name="period" type="duration" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="destinationOrderQosPolicy">
        <xs:all>
            <xs:element name="kind" type="destinationOrderKind"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="durabilityQosPolicy">
        <xs:all>
            <xs:element name="kind" type="durabilityKind" default="VOLATILE_DURABILITY_QOS"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="durabilityServiceQosPolicy">
        <xs:all>
            <xs:element name="service_cleanup_delay" type="duration"
                minOccurs="0" />
            <xs:element name="history_kind" type="historyKind"
                default="KEEP_LAST_HISTORY_QOS" minOccurs="0" />
            <xs:element name="history_depth" type="xs:positiveInteger"
                minOccurs="0" />
            <xs:element name="max_samples" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
            <xs:element name="max_instances" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
            <xs:element name="max_samples_per_instance" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="entityFactoryQosPolicy">
        <xs:all>
            <xs:element name="autoenable_created_entities" type="xs:boolean"
                default="true" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="groupDataQosPolicy">
        <xs:all>
            <xs:element name="value" type="xs:base64Binary"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="historyQosPolicy">
        <xs:all>
            <xs:element name="kind" type="historyKind" default="KEEP_LAST_HISTORY_QOS"
                minOccurs="0" />
            <xs:element name="depth" type="xs:positiveInteger"
                default="1" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="latencyBudgetQosPolicy">
        <xs:all>
            <xs:element name="duration" type="duration" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="lifespanQosPolicy">
        <xs:all>
            <xs:element name="duration" type="duration" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="livelinessQosPolicy">
        <xs:all>
            <xs:element name="kind" type="livelinessKind" default="AUTOMATIC_LIVELINESS_QOS"
                minOccurs="0" />
            <xs:element name="lease_duration" type="duration"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="ownershipQosPolicy">
        <xs:all>
            <xs:element name="kind" type="ownershipKind" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="ownershipStrengthQosPolicy">
        <xs:all>
            <xs:element name="value" type="xs:nonNegativeInteger"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="partitionQosPolicy">
        <xs:all>
            <xs:element name="name" type="stringSeq" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="presentationQosPolicy">
        <xs:all>
            <xs:element name="access_scope" type="presentationAccessScopeKind"
                default="INSTANCE_PRESENTATION_QOS" minOccurs="0" />
            <xs:element name="coherent_access" type="xs:boolean"
                default="false" minOccurs="0" />
            <xs:element name="ordered_access" type="xs:boolean"
                default="false" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="readerDataLifecycleQosPolicy">
        <xs:all>
            <xs:element name="autopurge_nowriter_samples_delay" type="duration"
                minOccurs="0" />
            <xs:element name="autopurge_disposed_samples_delay" type="duration"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="reliabilityQosPolicy">
        <xs:all>
            <xs:element name="kind" type="reliabilityKind" minOccurs="0" />
            <xs:element name="max_blocking_time" type="duration"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="resourceLimitsQosPolicy">
        <xs:all>
            <xs:element name="max_samples" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
            <xs:element name="max_instances" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
            <xs:element name="max_samples_per_instance" type="positiveInteger_UNLIMITED"
                minOccurs="0" />
            <xs:element name="initial_samples" type="xs:positiveInteger"
                minOccurs="0" />
            <xs:element name="initial_instances" type="xs:positiveInteger"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="timeBasedFilterQosPolicy">
        <xs:all>
            <xs:element name="minimum_separation" type="duration"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="topicDataQosPolicy">
        <xs:all>
            <xs:element name="value" type="xs:base64Binary"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="transportPriorityQosPolicy">
        <xs:all>
            <xs:element name="value" type="xs:nonNegativeInteger"
                minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <!-- userDataQosPolicy uses base64Binary encoding:
        * Allowed characters are all letters: a-z, A-Z,  digits: 0-9, the
          characters: '+' '/' '=' and ' ' +,/.=,the plus sign (+), the slash
          (/), the equals sign (=), and XML whitespace characters.
        * The number of non whitespace characters must be divisible by four.
        * Equals signs, which are used as padding, can only appear at the end
          of the value, and there can be zero, one, or two of them.
        * If there are two equals signs, they must be preceded by one of the
          following characters: A, Q, g, w.
        * If there is only one equals sign, it must be preceded by one of the
           following characters:
           A, E, I, M, Q, U, Y, c, g, k, o, s, w, 0, 4, 8. -->
    <xs:complexType name="userDataQosPolicy">
        <xs:all>
            <xs:element name="value" type="xs:base64Binary"
                minOccurs="0"></xs:element>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="writerDataLifecycleQosPolicy">
        <xs:all>
            <xs:element name="autodispose_unregistered_instances"
                type="xs:boolean" default="true" minOccurs="0" />
        </xs:all>
    </xs:complexType>

    <xs:complexType name="domainparticipantQos">
        <xs:all>
            <xs:element name="user_data" type="userDataQosPolicy"
                minOccurs="0"></xs:element>
            <xs:element name="entity_factory" type="entityFactoryQosPolicy"
                minOccurs="0"></xs:element>
        </xs:all>

        <xs:attribute name="name" type="elementName" />
        <xs:attribute name="base_name" type="elementNameReference" />
        <xs:attribute name="topic_filter" type="topicNameFilter" />
    </xs:complexType>

    <xs:complexType name="publisherQos">
        <xs:all>
            <xs:element name="presentation" type="presentationQosPolicy"
                minOccurs="0" />
            <xs:element name="partition" type="partitionQosPolicy"
                minOccurs="0" />
            <xs:element name="group_data" type="groupDataQosPolicy"
                minOccurs="0" />
            <xs:element name="entity_factory" type="entityFactoryQosPolicy"
                minOccurs="0" />
        </xs:all>

        <xs:attribute name="name" type="elementName" />
        <xs:attribute name="base_name" type="elementNameReference" />
        <xs:attribute name="topic_filter" type="topicNameFilter" />
    </xs:complexType>

    <xs:complexType name="subscriberQos">
        <xs:all>
            <xs:element name="presentation" type="presentationQosPolicy"
                minOccurs="0"></xs:element>
            <xs:element name="partition" type="partitionQosPolicy"
                minOccurs="0"></xs:element>
            <xs:element name="group_data" type="groupDataQosPolicy"
                minOccurs="0"></xs:element>
            <xs:element name="entity_factory" type="entityFactoryQosPolicy"
                minOccurs="0"></xs:element>
        </xs:all>

        <xs:attribute name="name" type="elementName" />
        <xs:attribute name="base_name" type="elementNameReference" />
        <xs:attribute name="topic_filter" type="topicNameFilter" />
    </xs:complexType>

    <xs:complexType name="topicQos">
        <xs:all>
            <xs:element name="topic_data" type="topicDataQosPolicy"
                minOccurs="0" />
            <xs:element name="durability" type="durabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="durability_service" type="durabilityServiceQosPolicy"
                minOccurs="0" />
            <xs:element name="deadline" type="deadlineQosPolicy"
                minOccurs="0" />
            <xs:element name="latency_budget" type="latencyBudgetQosPolicy"
                minOccurs="0" />
            <xs:element name="liveliness" type="livelinessQosPolicy"
                minOccurs="0" />
            <xs:element name="reliability" type="reliabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="destination_order" type="destinationOrderQosPolicy"
                minOccurs="0" />
            <xs:element name="history" type="historyQosPolicy"
                minOccurs="0" />
            <xs:element name="resource_limits" type="resourceLimitsQosPolicy"
                minOccurs="0" />
            <xs:element name="transport_priority" type="transportPriorityQosPolicy"
                minOccurs="0" />
            <xs:element name="lifespan" type="lifespanQosPolicy"
                minOccurs="0" />
            <xs:element name="ownership" type="ownershipQosPolicy"
                minOccurs="0" />
        </xs:all>

        <xs:attribute name="name" type="elementName"/>
        <xs:attribute name="base_name" type="elementNameReference"/>
        <xs:attribute name="topic_filter" type="topicNameFilter"/>
    </xs:complexType>

    <xs:complexType name="datareaderQos">
        <xs:all>
            <xs:element name="durability" type="durabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="deadline" type="deadlineQosPolicy"
                minOccurs="0" />
            <xs:element name="latency_budget" type="latencyBudgetQosPolicy"
                minOccurs="0" />
            <xs:element name="liveliness" type="livelinessQosPolicy"
                minOccurs="0" />
            <xs:element name="reliability" type="reliabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="destination_order" type="destinationOrderQosPolicy"
                minOccurs="0" />
            <xs:element name="history" type="historyQosPolicy"
                minOccurs="0" />
            <xs:element name="resource_limits" type="resourceLimitsQosPolicy"
                minOccurs="0" />
            <xs:element name="user_data" type="userDataQosPolicy"
                minOccurs="0" />
            <xs:element name="ownership" type="ownershipQosPolicy"
                minOccurs="0" />
            <xs:element name="time_based_filter" type="timeBasedFilterQosPolicy"
                minOccurs="0" />
            <xs:element name="reader_data_lifecycle" type="readerDataLifecycleQosPolicy"
                minOccurs="0" />
        </xs:all>

        <xs:attribute name="name" type="elementName" />
        <xs:attribute name="base_name" type="elementNameReference" />
        <xs:attribute name="topic_filter" type="topicNameFilter" />
    </xs:complexType>

    <xs:complexType name="datawriterQos">
        <xs:all>
            <xs:element name="durability" type="durabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="durability_service" type="durabilityServiceQosPolicy"
                minOccurs="0" />
            <xs:element name="deadline" type="deadlineQosPolicy"
                minOccurs="0" />
            <xs:element name="latency_budget" type="latencyBudgetQosPolicy"
                minOccurs="0" />
            <xs:element name="liveliness" type="livelinessQosPolicy"
                minOccurs="0" />
            <xs:element name="reliability" type="reliabilityQosPolicy"
                minOccurs="0" />
            <xs:element name="destination_order" type="destinationOrderQosPolicy"
                minOccurs="0" />
            <xs:element name="history" type="historyQosPolicy"
                minOccurs="0" />
            <xs:element name="resource_limits" type="resourceLimitsQosPolicy"
                minOccurs="0" />
            <xs:element name="transport_priority" type="transportPriorityQosPolicy"
                minOccurs="0" />
            <xs:element name="lifespan" type="lifespanQosPolicy"
                minOccurs="0" />
            <xs:element name="user_data" type="userDataQosPolicy"
                minOccurs="0" />
            <xs:element name="ownership" type="ownershipQosPolicy"
                minOccurs="0" />
            <xs:element name="ownership_strength" type="ownershipStrengthQosPolicy"
                minOccurs="0" />
            <xs:element name="writer_data_lifecycle" type="writerDataLifecycleQosPolicy"
                minOccurs="0" />
        </xs:all>

        <xs:attribute name="name" type="elementName" />
        <xs:attribute name="base_name" type="elementNameReference" />
        <xs:attribute name="topic_filter" type="topicNameFilter" />
    </xs:complexType>

    <xs:complexType name="domainparticipantQosProfile">
        <xs:complexContent>
            <xs:restriction base="domainparticipantQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="topicQosProfile">
        <xs:complexContent>
            <xs:restriction base="topicQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="publisherQosProfile">
        <xs:complexContent>
            <xs:restriction base="publisherQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="subscriberQosProfile">
        <xs:complexContent>
            <xs:restriction base="subscriberQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="datawriterQosProfile">
        <xs:complexContent>
            <xs:restriction base="datawriterQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="datareaderQosProfile">
        <xs:complexContent>
            <xs:restriction base="datareaderQos">
                <xs:attribute name="name" type="elementName" use="required" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="qosProfile">
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="datareader_qos" type="datareaderQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="datawriter_qos" type="datawriterQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="topic_qos" type="topicQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="domain_participant_qos" type="domainparticipantQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="publisher_qos" type="publisherQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="subscriber_qos" type="subscriberQos"
                    minOccurs="0" maxOccurs="unbounded" />
            </xs:choice>
        </xs:sequence>

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

    <xs:complexType name="qosLibrary">
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="qos_profile" type="qosProfile"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="datareader_qos" type="datareaderQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="datawriter_qos" type="datawriterQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="topic_qos" type="topicQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="domain_participant_qos" type="domainparticipantQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="publisher_qos" type="publisherQos"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="subscriber_qos" type="subscriberQos"
                    minOccurs="0" maxOccurs="unbounded" />
            </xs:choice>
        </xs:sequence>

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

</xs:schema>
