<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="www.dre.vanderbilt.edu"
           xmlns:ciao="www.dre.vanderbilt.edu"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">

  <xs:element name="orbPolicies">
    <xs:annotation>
      <xs:documentation>
        The root element of the schema. Contains zero or more policies.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="policy" type="ciao:policyType" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:complexType name="policyType">
    <xs:sequence>
      <xs:choice>
        <xs:element name="rebindPolicy" type="ciao:rebindPolicyType" />
        <xs:element name="syncScopePolicy" type="ciao:syncScopePolicyType" />
        <xs:element name="requestPriorityPolicy" type="ciao:requestPriorityPolicyType" />
        <xs:element name="replyPriorityPolicy" type="ciao:replyPriorityPolicyType" />
        <xs:element name="requestStartTimePolicy" type="ciao:requestStartTimePolicyType" />
        <xs:element name="requestEndTimePolicy" type="ciao:requestEndTimePolicyType" />
        <xs:element name="replyStartTimePolicy" type="ciao:replyStartTimePolicyType" />
        <xs:element name="replyEndTimePolicy" type="ciao:replyEndTimePolicyType" />
        <xs:element name="relativeRequestTimeoutPolicy" type="ciao:relativeRequestTimeoutPolicyType" />
        <xs:element name="relativeRoundtripPolicy" type="ciao:relativeRoundtripPolicyType" />
        <xs:element name="routingPolicy" type="ciao:routingPolicyType" />
        <xs:element name="maxHopsPolicy" type="ciao:maxHopsPolicyType" />
        <xs:element name="queueOrderPolicy" type="ciao:queueOrderPolicyType" />
        <xs:element name="priorityModelPolicy" type="ciao:priorityModelPolicyType" />
        <xs:element name="threadPoolPolicy" type="ciao:threadPoolPolicyType" />
        <xs:element name="serverProtocolPolicy" type="ciao:serverProtocolPolicyType" />
        <xs:element name="clientProtocolPolicy" type="ciao:clientProtocolPolicyType" />
        <xs:element name="privateConnectionPolicy" type="ciao:privateConnectionPolicyType" />
        <xs:element name="priorityBandedPolicy" type="ciao:priorityBandedPolicyType" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
    
  <xs:complexType name="policyBase" abstract="true">
    <xs:annotation>
      <xs:documentation>
        This is the base policy type.  All policies
        should be an extension of this type.  
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="override" type="ciao:overrideType" />
      <xs:element name="scope" type="ciao:scopeType" />
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="scopeType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="ORB" />
      <xs:enumeration value="THREAD" />
      <xs:enumeration value="OBJECT" />
      <xs:enumeration value="POA" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="policyIDType">
    <xs:annotation>
      <xs:documentation>
        This type represents the policy ID.  
        Need to add a restriction.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:integer">
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="overrideType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="SET_OVERRIDE" />
      <xs:enumeration value="ADD_OVERRIDE" />
    </xs:restriction>
  </xs:simpleType>
  

  
  <!-- The following are extensions of policyBase, one each for each policy 
       we may want to group these into seperate schema documents, for our
       own sanity.
  -->
  <!-- Policies 23 - 35 are defined in Messaging_No_Impl.pidl,
       with the exception of policy 32, defined in Messaging_RT_Policy.pidl
       and policy 24, defined in Messaging_SyncScope_Policy.pidl -->

  <xs:complexType name="rebindPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents the RebindPolicy type, ID 23
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="rebindMode" type="ciao:rebindModeType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="23" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:simpleType name="rebindModeType">
    <xs:annotation>
      <xs:documentation>
        Note:  This is not strictly represented in the pidl as an enum,
        but that appears to be the intent of the way it is declared.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="TRANSPARENT" />
      <xs:enumeration value="NO_REBIND" />
      <xs:enumeration value="NO_RECONNECT" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="syncScopePolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a SyncScopePolicyType, ID 24
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="synchronization" type="ciao:syncScopeType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="25" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:simpleType name="syncScopeType">
    <xs:annotation>
      <xs:documentation>
        Note: This was not declared an enum in Messaging_SyncScope_Policy.pidl,
        but from the declaration, that appears to be the intent.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="SYNC_NONE" />
      <xs:enumeration value="SYNC_WITH_TRANSPORT" />
      <xs:enumeration value="SYNC_WITH_SERVER" />
      <xs:enumeration value="SYNC_WITH_TARGET" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="requestPriorityPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RequestPriorityPolicy, ID 25
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="priorityRange" type="ciao:priorityRangeType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="25" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="replyPriorityPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a ReplyPriorityPolicy, ID 26
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="priorityRange" type="ciao:priorityRangeType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="26" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="priorityRangeType">
    <xs:annotation>
      <xs:documentation>
        Represents a PriorityRange struct defined in Messaging_No_Impl.pidl
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="min" type="xs:integer" />
      <xs:element name="max" type="xs:integer" />
    </xs:sequence>
  </xs:complexType>
  
  
  <xs:complexType name="requestStartTimePolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RequestStartTimePolicy, ID 27
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="startTime" type="ciao:utcTime" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="27" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  
  <xs:complexType name="requestEndTimePolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RequestEndTimePolicy, ID 28
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="endTime" type="ciao:utcTime" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="28" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  

  <xs:complexType name="replyStartTimePolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a ReplyStartTimePolicy, ID 29
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="startTime" type="ciao:utcTime" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="29" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  

  <xs:complexType name="replyEndTimePolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a ReplyEndTimePolicy, ID 30
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="endTime" type="ciao:utcTime" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="30" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="utcTime">
    <xs:annotation>
      <xs:documentation>
        Represents a TimeBase::UtcT struct, defined in tao/TimeBase.pidl
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="time" type="xs:integer" />
      <xs:element name="inaccLo" type="xs:integer" />
      <xs:element name="inaccHi" type="xs:integer" />
      <xs:element name="tdf" type="xs:integer" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="relativeRequestTimeoutPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RelativeRequestTimeoutPolicy, ID 31.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="relativeExpiry" type="xs:integer" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="31" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="relativeRoundtripPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RelativeRoundtripPolicy, ID 32
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="relativeExpiry" type="xs:integer" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="32" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="routingPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a RoutingPolicy, ID 33
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="routingTypeRangeMin" type="ciao:routingType" />
          <xs:element name="routingTypeRangeMax" type="ciao:routingType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="33" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:simpleType name="routingType">
    <xs:annotation>
      <xs:documentation>
        Note: This is not explicitly set up as an enum in Messaging_No_Impl.pidl,
        but that appears to be the intent from the declaration.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="ROUTE_NONE" />
      <xs:enumeration value="ROUTE_FORWARD" />
      <xs:enumeration value="ROUTE_STORE_AND_FORWARD" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="maxHopsPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a MaxHopsPolicy, ID 34
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="maxHops" type="xs:integer" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="34" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="queueOrderPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents a QueueOrderPolicy, ID 35
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="allowedOrders" type="ciao:ordersType" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="35" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:simpleType name="ordersType">
    <xs:annotation>
      <xs:documentation>
        Note: This is not explicitly declared to be an enum in Messaging_No_Impl.pidl,
        but that appears to be the intent from the declaration.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="ORDER_ANY" />
      <xs:enumeration value="ORDER_TEMPORAL" />
      <xs:enumeration value="ORDER_PRIORITY" />
      <xs:enumeration value="ORDER_DEADLINE" />
    </xs:restriction>
  </xs:simpleType>

  <!-- Policies 40 - 45 are defined in RTCORBA.pidl -->
  <!-- priorityModelPolicy -->
  <xs:complexType name="priorityModelPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents the Priority Model Policy, ID 40
      </xs:documentation>
    </xs:annotation>
    
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="priorityModel" type="ciao:priorityModelType" />
          <xs:element name="serverPriority" type="xs:integer" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="40" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:simpleType name="priorityModelType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="CLIENT_PROPAGATED" />
      <xs:enumeration value="SERVER_DECLARED" />
    </xs:restriction>
  </xs:simpleType>

  <!-- threadPoolPolicy -->

  <xs:complexType name="threadPoolPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents the ThreadPool policy, ID 41
      </xs:documentation>
    </xs:annotation>
    
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="threadPoolID" type="xs:integer" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="41" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  
  <!-- serverProtocolPolicy -->

  <xs:complexType name="serverProtocolPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents the Server Protocol policy, ID 42
      </xs:documentation>
    </xs:annotation>
    
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="protocol" type="ciao:protocolType"
                      minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="42" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  
  <!-- clientProtocolPolicy -->
  <xs:complexType name="clientProtocolPolicyType">
    <xs:annotation>
      <xs:documentation>
        Represents the Client Protocol policy, ID 43
      </xs:documentation>
    </xs:annotation>
    
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="protocol" type="ciao:protocolType"
                      minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="43" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  

  <!-- Protocol definitions for client and server Protocol properties types. -->
  <xs:complexType name="protocolType">
    <xs:sequence>
      <xs:element name="protocolType" type="xs:integer" />
      <xs:element name="orbProtocolProperties" type="ciao:protocolPropertyType" />
      <xs:element name="transportProtocolProperties" type="ciao:protocolPropertyType" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="protocolPropertyType">
    <xs:sequence>
      <xs:choice>
        <xs:element name="tcpProtocolProperties" type="ciao:tcpProtocolPropertiesType" />
        <xs:element name="giopProtocolProperties" type="ciao:giopProtocolPropertiesType" />
        <xs:element name="unixDomainProtocolProperties" type="ciao:unixDomainProtocolPropertiesType" />
        <xs:element name="sharedMemoryProtocolProperties" type="ciao:sharedMemoryProtocolPropertiesType" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="protocolPropertyBase" abstract="true">
    <xs:annotation>
      <xs:documentation>
        Base type for all protocol properties.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="type" type="xs:string" use="required" />
  </xs:complexType>
  
  <xs:complexType name="tcpProtocolPropertiesType">
    <xs:complexContent>
      <xs:extension base="ciao:protocolPropertyBase">
        <xs:sequence>
          <xs:element name="sendBufferSize" type="xs:integer" />
          <xs:element name="recvBufferSize" type="xs:integer" />
          <xs:element name="keepAlive" type="xs:boolean" />
          <xs:element name="dontRoute" type="xs:boolean" />
          <xs:element name="noDelay" type="xs:boolean" />
          <xs:element name="enableNetworkPriority" type="xs:boolean" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="giopProtocolPropertiesType">
    <xs:complexContent>
      <xs:extension base="ciao:protocolPropertyBase" />
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="unixDomainProtocolPropertiesType">
    <xs:complexContent>
      <xs:extension base="ciao:protocolPropertyBase">
        <xs:sequence>
          <xs:element name="sendBufferSize" type="xs:integer" />
          <xs:element name="recvBufferSize" type="xs:integer" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="sharedMemoryProtocolPropertiesType">
    <xs:complexContent>
      <xs:extension base="ciao:protocolPropertyBase">
        <xs:sequence>
          <xs:element name="preallocateBufferSize" type="xs:integer" />
          <xs:element name="mmapFilename" type="xs:string" />
          <xs:element name="mmapLockname" type="xs:string" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
        
  <!-- TODO:  Provide other protocolProperties types -->

  <!-- privateConnectionPolicy -->
  <xs:complexType name="privateConnectionPolicyType">
    <xs:annotation>
      <xs:documentation>
        privateConnectionPolicy extension of policyBase, ID 44
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <!-- empty -->
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="44" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  
  <!-- priorityBandedPolicy -->
  <xs:complexType name="priorityBandedPolicyType">
    <xs:annotation>
      <xs:documentation>
        priorityBandedPolicy extension of policyBase, ID 45
      </xs:documentation>
    </xs:annotation>
    
    <xs:complexContent>
      <xs:extension base="ciao:policyBase">
        <xs:sequence>
          <xs:element name="priorityBand" type="ciao:priorityBandType"
                      minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="typeID" type="xs:integer" use="required" fixed="45" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  
  <xs:complexType name="priorityBandType">
    <xs:annotation>
      <xs:documentation>
        Represents the PriorityBand struct for the priorityBandedPolicy element.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="low" type="xs:integer" />
      <xs:element name="high" type="xs:integer" />
    </xs:sequence>
  </xs:complexType>
  


</xs:schema>