<?xml version="1.0" encoding="UTF-8"?>
<!--
   (c) Copyright, Real-Time Innovations, Inc. 2001.  All rights reserved.
   No duplications, whole or partial, manual or electronic, may be made
   without prior written permission.  Any such copies, or
   revisions thereof, must display this notice unaltered.
   This code contains trade secrets of Real-Time Innovations, Inc.
-->

<!-- =================================================================== -->
<!-- RTI Persistence Service XML Schema File                             -->
<!-- =================================================================== -->

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


    <xs:include schemaLocation="definitions/rti_dds_profiles_definitions.xsd"/>
    <xs:include schemaLocation="definitions/rti_dist_logger_definitions.xsd"/>

    <!-- =================================================================== -->
    <!-- Main Elements                                                       -->
    <!-- =================================================================== -->

    <xs:element name="dds">
        <xs:annotation>
            <xs:documentation>
                Configuration of RTI DDS and RTI DDS Services.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="configuration_variables" type="KeyValuePairSeq">
                    <xs:annotation>
                        <xs:documentation>
                            <![CDATA[
                            Defines a set of default values for user variables.
                            The values specified in this section can be overridden
                            by environment variables.
                            ]]>
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element ref="persistence_service"/>
                <xs:element name="qos_library" type="qosLibrary"/>
                <xs:element name="domain_library" type="domainLibrary"/>
                <xs:element name="domain_participant_library" type="participantLibrary"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>

    <!-- =================================================================== -->

    <xs:element name="persistence_service">
        <xs:annotation>
            <xs:documentation>
                Configuration of an execution of RTI Persistence Service
            </xs:documentation>
        </xs:annotation>
        <xs:complexType >

            <xs:sequence>
                <xs:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="1" />
                <xs:element ref="administration" minOccurs="0" maxOccurs="1" />
                <xs:element ref="persistent_storage" minOccurs="0" maxOccurs="1" />
                <xs:element ref="synchronization" minOccurs="0" maxOccurs="1" />
                <xs:element ref="purge_samples_after_acknowledgment" minOccurs="0" maxOccurs="1" />
                <xs:element ref="participant" minOccurs="1" maxOccurs="unbounded" />
            </xs:sequence>

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

    <!-- =================================================================== -->

    <xs:element name="administration">
        <xs:annotation>
            <xs:documentation>
                Remote administration configuration.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:choice minOccurs="1" maxOccurs="unbounded">
                    <xs:element name="domain_id"
                            type="positiveInteger_DOMAIN_ID"
                            minOccurs="1" maxOccurs="1"/>
                    <xs:element name="distributed_logger"
                            type="distributedLogger"
                            minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                                Configuration settings for Distributed Logger.
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="domain_participant_qos"
                            type="domainParticipantQosProfileChild"
                            minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                                <![CDATA[
                                Sets the participant QoS. The contents of this tag are
                                specified in the same manner as a [NDDS] QoS profile
                                file.

                                Use the attribute base_name to inherit from an
                                existing profile. Default: DDS defaults.
                                ]]>
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="participant_qos"
                            type="domainParticipantQosProfileChild"
                            minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                                <![CDATA[
                                Sets the participant QoS. The contents of this tag are
                                specified in the same manner as a [NDDS] QoS profile
                                file.

                                Use the attribute base_name to inherit from an
                                existing profile. Default: DDS defaults.

                                The participant_qos tag has been deprecated, in favor of the
                                standard domain_participant_qos tag. Please use
                                domain_participant_qos instead.
                                ]]>
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="publisher_qos"
                            type="publisherQosProfileChild"
                            minOccurs="0" maxOccurs="1"/>
                    <xs:element name="subscriber_qos"
                            type="subscriberQosProfileChild"
                            minOccurs="0" maxOccurs="1"/>
                    <xs:element name="datareader_qos"
                            type="dataReaderQosProfileChild"
                            minOccurs="0" maxOccurs="1"/>
                    <xs:element name="datawriter_qos"
                            type="dataWriterQosProfileChild"
                            minOccurs="0" maxOccurs="1"/>
                </xs:choice>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- =================================================================== -->

    <xs:element name="persistent_storage">
        <xs:annotation>
            <xs:documentation>
                Configuration of the persistent storage to store the topic data
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
            <xs:choice minOccurs="1" maxOccurs="1">
                <xs:element ref="filesystem" />
            </xs:choice>
            <xs:element ref="restore" minOccurs="0" maxOccurs="1"/>
            <xs:element name="type_object_max_serialized_length" type="xs:positiveInteger" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="filesystem">
        <xs:annotation>
            <xs:documentation>
                Persist data in the filesystem
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:all>
                <xs:element name="directory" type="xs:string" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            The directory where the files to persist the data will be placed.
                            Default: current working directory
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="file_prefix" type="xs:string" minOccurs="0" maxOccurs="1" default="PS">
                    <xs:annotation>
                        <xs:documentation>
                            A prefix for all the files created by RTI Persistence Service.
                            Default: PS
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="synchronization" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Determines the level of synchronization of the
                            data to store with the physical disk.
                            Default: NORMAL.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="FULL">
                                <xs:annotation>
                                    <xs:documentation>
                                        Every sample is written into physical disk as
                                        RTI Persistence Service receives it
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="NORMAL">
                                <xs:annotation>
                                    <xs:documentation>
                                        Samples are written into physical disk at
                                        critical moments
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="OFF">
                                <xs:annotation>
                                    <xs:documentation>
                                        No synchronization is enforced. Data will
                                        be written to phyisical disk at the OS's
                                        discretion
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="journal_mode" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Sets the journal mode.
                            Default: WAL.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="DELETE">
                                <xs:annotation>
                                    <xs:documentation>
                                        The rollback journal is deleted at the conclusion
                                        of each transaction.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="TRUNCATE">
                                <xs:annotation>
                                    <xs:documentation>
                                        This mode commits transactions by truncating the
                                        rollback journal to zero-length instead of deleting it.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="PERSIST">
                                <xs:annotation>
                                    <xs:documentation>
                                        This mode prevents the rollback journal from being
                                        deleted at the end of each transaction. Instead,
                                        the header of the journal is overwritten with zeros.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="MEMORY">
                                <xs:annotation>
                                    <xs:documentation>
                                        This mode stores the rollback journal in volatile RAM.
                                        This saves disk I/O but at the expense of database
                                        safety and integrity.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="WAL">
                                <xs:annotation>
                                    <xs:documentation>
                                        The WAL journaling mode uses a write-ahead log instead
                                        of a rollback journal to implement transactions.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="OFF">
                                <xs:annotation>
                                    <xs:documentation>
                                        The OFF journaling mode disables the rollback journal
                                        completely.
                                        If the application crashes in the middle of a transaction
                                        when the OFF journaling mode is set, then the files containing
                                        the samples will very likely go corrupt.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="vacuum" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Sets the auto-vacuum status of the storage.
                            Default: FULL.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="NONE">
                                <xs:annotation>
                                    <xs:documentation>
                                        When auto-vacuum is disabled and data is deleted from the storage files,
                                        the files remain the same size.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="FULL">
                                <xs:annotation>
                                    <xs:documentation>
                                        The storage files are compacted after every transaction.
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                            <xs:enumeration value="INCREMENTAL">
                                <xs:annotation>
                                    <xs:documentation>
                                        &lt;NOT SUPPORTED&gt;
                                    </xs:documentation>
                                </xs:annotation>
                            </xs:enumeration>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="trace_file" type="xs:string" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Trace file for debug information.
                            Default: None
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:all>
        </xs:complexType>
    </xs:element>


    <!-- =================================================================== -->

    <xs:element name="participant">
        <xs:annotation>
            <xs:documentation>
                For each participant
                tag, RTI Persistence Service creates two
                DDS DomainParticipants on the same domain ID:
                one to subscribe to changes and one to publish changes.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:choice minOccurs="1" maxOccurs="unbounded">
                    <xs:element ref="domain_id" minOccurs="0" maxOccurs="1"/>
                    <xs:element name="domain_participant_qos" type="domainParticipantQos" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                                <![CDATA[
                                Sets the participant QoS. The contents of this tag are
                                specified in the same manner as a [NDDS] QoS profile
                                file.

                                Use the attribute base_name to inherit from an
                                existing profile. Default: DDS defaults.
                                ]]>
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="participant_qos" type="domainParticipantQos" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>
                                <![CDATA[
                                Sets the participant QoS. The contents of this tag are
                                specified in the same manner as a [NDDS] QoS profile
                                file.

                                Use the attribute base_name to inherit from an
                                existing profile. Default: DDS defaults.

                                The participant_qos tag has been deprecated, in favor of the
                                standard domain_participant_qos tag. Please use
                                domain_participant_qos instead.
                                ]]>
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element ref="durable_subscriptions" minOccurs="0" maxOccurs="1"/>
                    <xs:element ref="persistence_group" minOccurs="1" maxOccurs="unbounded"/>
                </xs:choice>
            </xs:sequence>
            <xs:attribute name="name" use="optional" type="xs:NCName"/>
        </xs:complexType>
    </xs:element>

    <!-- =================================================================== -->

    <xs:element name="memory_management">
        <xs:annotation>
            <xs:documentation>
                Configures different aspects of the internal memory management for
                the data persisted within this persistence group
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:all>
                <xs:element name="pool_sample_buffer_max_size"
                            type="nonNegativeIntegerUnlimited"
                            minOccurs="0" maxOccurs="1"/>
                <xs:element name="persistent_sample_buffer_max_size"
                            type="nonNegativeIntegerUnlimited"
                            minOccurs="0" maxOccurs="1"/>
            </xs:all>
        </xs:complexType>
    </xs:element>


    <!-- =================================================================== -->
    <xs:element name="durable_subscriptions">
        <xs:annotation>
            <xs:documentation>
                Durable subscriptions for a given topic.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="element" type="durableSubscription" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- =================================================================== -->

    <xs:element name="persistence_group">
        <xs:annotation>
            <xs:documentation>
                A persistence group describes a set of topics whose data
                must be persisted by the persistence service.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:all>
                <xs:element name="filter" type="xs:string" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            A list of POSIX expressions separated by commas that describe
                            the set of topics associated with the persistence group.
                            The filter can be specified as an attribute of persistence_group
                            as well. Default: *
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="deny_filter" type="xs:string" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            A list of POSIX expressions separated by commas that describe
                            the set of topics denied in the persistence group.
                            This "black" list is applied after 'filter'.
                            Default: empty
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="content_filter"  type="xs:string" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Content filter topic expression. A persistence group can subscribe
                            to a specific set of data based on the value of this expression.
                            Default: no expression.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="propagate_dispose" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls whether or not the
                            persistence service propagates dispose messages from DataWriters
                            to DataReaders. Default: true
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="propagate_unregister" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls whether or not the
                            persistence service propagates unregister messages from
                            DataWriters to DataReaders. Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="propagate_source_timestamp" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls whether or not the
                            persistence service propagates the source timestamp
                            of the received samples. Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="propagate_related_source_guid" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls whether or not the
                            persistence service propagates the related source
                            GUID of the received samples. Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="single_publisher" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Indicates if the persistence
                            service should create one Publisher per persistence group (true) or one
                            Publisher per PRSTDataWriter inside the persistence group (false).
                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="single_subscriber" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Indicates if the persistence
                            service should create one Subscriber per persistence group (true) or
                            one Subscriber per PRSTDataReader in the persistence group (false).
                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="use_durability_service" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Indicates if the HISTORY
                            and RESOURCE_LIMITS QoS policy of the PRSTDataWriters
                            and PRSTDataReaders should be configured based on the
                            DURABILITY SERVICE value of the discovered DataWriters.
                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="reader_checkpoint_frequency" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls how often (expressed as a number of
                            samples) the PRSTDataReader state is stored in the database.
                            The PRSTDataReaders are the DDS DataReaders created by the
                            persistence service.
                            This property is only applicable when the persistence service
                            operates in persistent mode (the persistent_storage tag is present)
                            Default: 1
            </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="writer_in_memory_state" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Determines how much state
                            will be kept in memory by the PRSTDataWriters in order to
                            avoid accessing the database.
                            The property is only applicable when the persistence service
                            operates in persistent mode (the persistent_storage tag is present).
                            Default: For KEEP_LAST or ResourceLimitsQosPolicy.
                            max_samples != DDS_UNLIMITED_LENGTH, the default is true.
                            Otherwise, the default is false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="writer_checkpoint_period" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls how often (expressed as a number of
                            milliseconds) transactions are committed for a PRSTDataWriter.
                            Default: 0
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="writer_checkpoint_volume" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls how often (expressed as a number of
                            samples) transactions are committed for a PRSTDataWriter.
                            Default: 1
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="writer_ack_period" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls how often (expressed as a number of
                            milliseconds) samples are marked as ACKed in the database by
                            the PRSTDataWriter.
                            Default: 0
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="late_joiner_read_batch" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Defines how many samples will be pre-fetched by a PRSTDataWriter to satisfy late joiner requests.
                            Default: 20000
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="allow_durable_subscriptions" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Enables support for durable subscriptions in the PRSTDataWriters.
                            When durable subscriptions are not required setting this property to false will
                            increase performance.

                            Default: true
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="use_wait_set" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            [DEPRECATED] Indicates if the persistence service
                            will use waitsets or listeners to read data from the
                            PRSTDataReaders.

                            This tag is deprecated and will be removed in
                            a future release. Persistence Service will always
                            use waitsets to read data from the PRSTDataReaders.

                            Default: true
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element ref="memory_management" minOccurs="0" maxOccurs="1" />
                <xs:element ref="sample_logging" minOccurs="0" maxOccurs="1"/>
                <xs:element name="topic_qos" type="topicQos" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation></xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="publisher_qos" type="publisherQos" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>QoS for the Publishers</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="subscriber_qos" type="subscriberQos" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>QoS for the Subscribers</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="datawriter_qos" type="dataWriterQos" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>QoS for the DataWriters</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="datareader_qos" type="dataReaderQos" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>QoS for the DataReaders</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:all>
            <xs:attribute name="name" use="optional" type="xs:NCName"/>
        </xs:complexType>
    </xs:element>


    <!-- =================================================================== -->


    <!-- =================================================================== -->
    <!-- Basic types                                                         -->
    <!-- =================================================================== -->

    <xs:complexType name="annotationType">
        <xs:all>
            <xs:element name="documentation" type="xs:string" minOccurs="0" maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

    <xs:element name="dsn" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                DSN used to connect to the database using ODBC. You should
                create this DSN through the ODBC settings on Windows systems,
                or in your .odbc.ini file on UNIX/Linux systems.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="username" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                Username for the data base connection.
                Default: no user name
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="password" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                Password for the data base connection.
                Default: no password
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="restore" type="xs:boolean">
        <xs:annotation>
            <xs:documentation>
                Indicates if the topic data
                associated with a previous execution of the persistence service
                must be restored or not. If the topic data is not restored, it will be
                deleted from the database. Default: true
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="odbc_library" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                Specifies the ODBC driver to load. By default, RTI Connext
                will try to use the standard ODBC driver manager
                library (UnixOdbc on UNIX/Linux systems, the Windows
                ODBC driver manager on Windows systems).
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="domain_id">
        <xs:annotation>
            <xs:documentation>
                Domain ID associated with the Participant. Default: 0
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:nonNegativeInteger"/>
        </xs:simpleType>
    </xs:element>

    <xs:element name="topic_name">
        <xs:annotation>
            <xs:documentation>
                The topic name that will be subscribed to and whose
                received values will be stored in the associated table
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string" />
        </xs:simpleType>
    </xs:element>

    <xs:element name="type_name">
        <xs:annotation>
            <xs:documentation>
                The type name of the topic that will be subscribed to
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string" />
        </xs:simpleType>
    </xs:element>

    <xs:element name="profile_name">
        <xs:annotation>
            <xs:documentation>
                This column specifies the name of the QoS Profile that RTI Real-Time Connect will use to
                create the subscription. Syntax: QosLibraryName::QosProfileName
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string" />
        </xs:simpleType>
    </xs:element>

    <xs:element name="data_synchronization">
        <xs:annotation>
            <xs:documentation>
                This tag can be used to enable and configure data synchronization
                between redundant persistence service instances using
                a gossip algorithm that minimizes the impact of the
                synchronization on the performance of the system.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="enable"  type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            When set to true, data synchronization is enabled.
                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="remote_provider_selection_period" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                        Controls how often (expressed in milliseconds)
                        a Persistence Service instance evaluates the remote DataWriter
                        (remote provider) from which it will be getting DDS samples
                        published by the original DataWriter.
                        If a Persistence Service instance is connected directly to
                        the original DataWriter, it will pick the original DataWriter as
                        its remote provider.

                        Default: 5000
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="stable_provider_period_count" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                        Specifies the number of consecutive remote_provider_selection_periods
                        during which the selected set of remote providers must remain
                        unchanged before the selection is considered stable.
                        When a new set of remote providers is selected for a
                        (DataReader, DataWriter) pair, the Persistence Service waits
                        for this number of periods without any change in the selection.
                        Once stability is confirmed, the ContentFilteredTopic
                        associated with the DataReader is updated to begin receiving
                        samples from the selected remote providers.
                        If set to 1, the Persistence Service considers the
                        selection stable immediately after it is made, and switches
                        to the new providers without waiting.

                        Default: 1
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="max_remote_provider_change_period_count" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                        Sets an upper limit
                        on how long the Persistence Service may tolerate instability
                        in remote provider selection for a given (DataReader, DataWriter)
                        pair. Specifically, this property defines the maximum number of
                        consecutive remote_provider_selection_periods during which
                        the set of selected remote providers is allowed to change.
                        If this threshold is reached without the selection stabilizing,
                        the Persistence Service will stop waiting, adopt the most
                        recently selected set of remote providers, and consider
                        the selection stable.
                        This property must be greater than or equal to
                        stable_provider_period_count.
                        Its purpose is to prevent indefinite oscillation in provider
                        selection, which may occur due to fluctuating network
                        conditions, intermittent provider availability, or other
                        transient issues. Such instability can lead to:
                        - Unreliable system behavior
                        - Increased latency in data reception
                        - Excessive processing overhead
                        By enforcing this limit, the service ensures progress and
                        system responsiveness even when perfect stability is
                        not achievable.

                        Default: 1
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="enable_sync_builtin_filter" type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            When set to true, the Persistence Service
                            will use a built-in specialized Content Filter to
                            perform data synchronization. This built-in filter
                            is optimized for the synchronization use case and
                            is more efficient than the SQL-based filter used in
                            early implementations.
                            Default: true
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="synchronization">
        <xs:annotation>
            <xs:documentation>
                Indicates if redundant persistence
                service instances should synchronize their states with
                one another.
                Default: NO synchronization
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="synchronize_data"  type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            [Deprecated]

                            When set to true, data messages lost on the way to one service
                            instance can be repaired by another without impacting the original
                            publisher of that message.
                            This tag enables the old synchronization protocol and
                            is deprecated. Use the 'data_synchronization' tag instead.

                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element ref="data_synchronization" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            This tag can be used to enable and configure data
                            synchronization between redundant persistence
                            service instances using a gossip algorithm that
                            minimizes the impact of the synchronization on the
                            performance of the system.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="synchronize_durable_subscription"  type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            When set to true, durable subscriptions and their state will be
                            synchronized across the different instances of persistence service.

                            Default: false
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="durable_subscription_synchronization_period" type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Controls how often (expressed as a number of
                            milliseconds) the state of a durable subscription is synchronized
                            with other persistence services.

                            Default: 5000
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="purge_samples_after_acknowledgment" type="xs:boolean">
        <xs:annotation>
            <xs:documentation>
                Indicates if persistence service must purge samples after they
                are acknowledged.

                When persistence service runs with this flag set to true, samples
                are removed from the PRSTDataWriters' queues as soon as they are
                acknowledged by all of the live DataReaders and all of the durable
                subscriptions.

                When persistence service runs with this flag set to false, the
                local durability of the PRSTDataWriters is configured to be
                TRANSIENT_LOCAL. Acknowledged samples are kept in the
                PRSTDataWriters' queues until new resources are needed.

                Default: false
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="sample_logging">
        <xs:annotation>
            <xs:documentation>
                This tag can be used to enable and configure a sample log for
                the PRSTDataWriters in a persistence group.
                A sample log is a buffer of samples on disk that,
                when used in combination with delegated reliability,
                allows decoupling the original DataWriters from slow DataReaders.

                Default: NO sample logging
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:all>
                <xs:element name="enable"  type="xs:boolean" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Indicates whether or not sample logging is enabled.

                            Default: 0
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="log_read_batch"  type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Determines how many samples should be read and processed at once by the sample
                            log write thread.

                            Default: 100
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="log_file_size"  type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Specifies the maximum size of a sample log file in Mbytes. When a log file becomes full,
                            persistence service creates a new log file.

                            Default: 60 MB
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="log_flush_period"  type="xs:positiveInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            The period (in milliseconds) at which persistence service removes sample
                            log files whose full content have been written into the
                            PRSTDataWriter by the sample log write thread.

                            Default: 10000 millisec
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="log_bookmark_period" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            Indicates how often (in milliseconds) the read bookmark is persisted into disk.

                            Default: 1000 millisec
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:all>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="durableSubscription">
        <xs:annotation>
            <xs:documentation>
                Describes a durable subscription.
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="quorum_count" type="positiveInteger_UNLIMITED" minOccurs="0" maxOccurs="1"/>
            <xs:element name="topic_name" type="xs:string" minOccurs="1" maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

    <!-- =================================================================== -->

    <xs:simpleType name="positiveInteger_DOMAIN_ID">
        <xs:annotation>
            <xs:documentation>
                Sets the domain ID associated with the participant.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

</xs:schema>
