<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="<http://www.w3.org/2001/XMLSchema>"
   xmlns:ncEvent="urn:ietf:params:xml:ns:netconf:notification:1.0"
   xmlns:manageEvent="urn:ietf:params:xml:ns:netmod:notification"
   xmlns="urn:ericsson:com:netconf:notification:1.0"
   targetNamespace="urn:ericsson:com:netconf:notification:1.0"
   elementFormDefault="qualified"
   attributeFormDefault="unqualified"
   xml:lang="en" version="1.0">

   <xs:annotation>
      <xs:documentation xml:lang="en">
         This schema defines the structure of the notifications sent by
         notification service component of COM.
      </xs:documentation>
   </xs:annotation>

   <xs:import
      namespace="urn:ietf:params:xml:ns:netconf:notification:1.0"
      schemaLocation="notification.xsd" />

   <xs:import namespace="urn:ietf:params:xml:ns:netmod:notification"
      schemaLocation="notificationmanagement.xsd" />

   <!-- Three types of events for create-subscription filters... -->
   <xs:simpleType name="EventStringType">
      <xs:restriction base="xs:string">
         <xs:annotation>
            <xs:documentation xml:lang="en">
               Enumeration of the strings representing the possible
               types of events supported by the COM notification
               service.
            </xs:documentation>
         </xs:annotation>
         <xs:enumeration value="ObjectCreated" />
         <xs:enumeration value="ObjectDeleted" />
         <xs:enumeration value="AttributeChanged" />
      </xs:restriction>
   </xs:simpleType>

   <!-- Type of the tag <event>, inside the tag <filter> of a
   create-subscription message -->
   <xs:complexType name="COMEventFilterType">
      <xs:complexContent>
         <xs:restriction base="xs:anyType">
            <xs:annotation>
               <xs:documentation xml:lang="en">
                  Structure of the element(s) to be included in the
                  filter element of the create-subscription message.
               </xs:documentation>
            </xs:annotation>
            <xs:sequence>
               <xs:element name="filterType" type="EventStringType"/>
               <xs:element name="filterValue" type="xs:string"/>
            </xs:sequence>
         </xs:restriction>
      </xs:complexContent>
   </xs:complexType>

   <!-- Declaration of the tag <event>, to be referenced in
   netconf.xsd schema, redefinition of netconf-RFC4741.xsd -->
   <xs:element name="event" type="COMEventFilterType" />

   <!-- Restriction of string simple type applied to dn strings -->
        <xs:simpleType name="dnType">
           <xs:annotation>
              <xs:documentation xml:lang="en">
                 Pattern to match a string representing the dn of the
                 MO which triggered a notification.
               </xs:documentation>
            </xs:annotation>
            <xs:restriction base="xs:string">
               <xs:pattern value="[a-zA-Z0-9]+=[a-zA-Z0-9]+(,*[a-zA-Z0-9]+=[a-zA-Z0-9]+)*"/>
            </xs:restriction>
   </xs:simpleType>

   <!-- Type of value tags -->
   <xs:complexType name="valueType" mixed="true">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Type of the tag &lt;v&gt;, containing a value for an
            attribute of a MO. Content can be a string (case of a
            single value), or a sequence of &lt;elem&gt; nodes (case
            of value is a struct).
         </xs:documentation>
      </xs:annotation>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:element name="elem" type="vSequenceType">
            <xs:annotation>
               <xs:documentation xml:lang="en">
                  Tag &lt;elem&gt;, containing a list of values of a
                  struct entry. Requires a 'name' attribute.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:sequence>
   </xs:complexType>

   <!-- Base type of tags which require a name attribute (attr and
   elem) -->
   <xs:complexType name="tagWithNameAttrType">
      <xs:complexContent>
         <xs:restriction base="xs:anyType">
            <xs:attribute name="name" type="xs:string" use="required" />
         </xs:restriction>
      </xs:complexContent>
   </xs:complexType>

   <!-- Type of attr and elem tags (content is a sequence of v tags) -->
   <xs:complexType name="vSequenceType">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Type of tags &lt;attr&gt; and &lt;elem&gt;. Content is a
            list of all the values of the MO attribute or struct entry.
            Tags require a 'name' attribute.
         </xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="tagWithNameAttrType">
            <xs:sequence minOccurs="0" maxOccurs="unbounded">
               <xs:element name="v" type="valueType"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <!-- Base type of the three possible event tags AVC, objectCreated,
   objectDeleted -->
   <xs:complexType name="eventType">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Base type of the tags representing a MO event:
            &lt;AVC&gt;, &lt;objectCreated&gt;, &lt;objectDeleted&gt;.
            These tags require a 'dn' attribute.
         </xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:restriction base="xs:anyType">
            <xs:attribute name="dn" type="dnType" use="required" />
         </xs:restriction>
      </xs:complexContent>
   </xs:complexType>

   <!-- Extension of the event type for AVC and objectCreated,
   describing content -->
   <xs:complexType name="attrEventType">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Type for event tags which must display the content of the
            attributes of a MO (&lt;AVC&gt; and &lt;objectCreated&gt;).
            Content is a list of &lt;attr&gt; elements.
         </xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="eventType">
            <xs:sequence>
               <xs:element name="attr" type="vSequenceType"
               minOccurs="1" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation xml:lang="en">
                        Tag &lt;attr&gt;, containing a list of all
                        values of a MO attribute. Requires a 'name'
                        attribute.
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <!-- Type of the tag <events>, containing COM Notifiation content -->
   <xs:complexType name="eventsType">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Type for &lt;events&gt; tag, containing a sequence of
            event tags (&lt;AVC&gt;, &lt;objectCreated&gt; or
            &lt;objectDeleted&gt;).
         </xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="ncEvent:NotificationContentType">
            <xs:sequence minOccurs="1" maxOccurs="unbounded">
               <xs:choice>
                  <xs:element name="AVC" type="attrEventType"/>
                  <xs:element name="objectCreated" type="eventType"/>
                  <xs:element name="objectDeleted" type="eventType"/>
               </xs:choice>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <!-- Declaration of the element <events> -->
   <xs:element name="events" type="eventsType"
   substitutionGroup="ncEvent:notificationContent">
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Tag to be sent in a &lt;notification&gt; message to inform
            about one or more MO events (attribute value changed -AVC-,
            object created or object deleted).
         </xs:documentation>
      </xs:annotation>
   </xs:element>

   <!-- Declaration of the element <CMSynchronizationRecommended> -->
   <xs:element name="CMSynchronizationRecommended"
   substitutionGroup="ncEvent:notificationContent" >
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Tag to be sent in a &lt;notification&gt; message to inform
            about an overflow in the queue of notification messages for
            this subscription.
         </xs:documentation>
      </xs:annotation>
   </xs:element>

   <!-- Declaration of the element <replayTimeUnsupported> -->
   <xs:element name="replayTimeUnsupported"
   substitutionGroup="ncEvent:notificationContent" >
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Tag to be sent in a  &lt;notification&gt; message to inform
            that the start time specified in a 'create subscription'
            message (for a subscription with replay) is earlier than
            the earliest time stored in the replay buffer.
         </xs:documentation>
      </xs:annotation>
   </xs:element>

   <!-- Declaration of the element <heartbeat> -->
      <xs:element name="heartbeat"
      substitutionGroup="ncEvent:notificationContent" >
      <xs:annotation>
         <xs:documentation xml:lang="en">
            Tag to be sent in a  &lt;notification&gt; message to inform
            that the heartbeat interval has expired.This is a periodic 
            notification.
         </xs:documentation>
      </xs:annotation>
   </xs:element>

<!-- <create-subscription> operation -->
   <xs:complexType name="createSubscriptionType">
     <xs:complexContent>
       <xs:extension base="netconf:rpcOperationType">
         <xs:sequence>
           <xs:element name="stream"
            type="streamNameType" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
               An optional parameter that indicates
               which stream of events is of interest.
               If not present, then events in the
               default NETCONF stream will be sent.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
            <xs:element name="filter"
              type="netconf:filterInlineType"
              minOccurs="0">
              <xs:annotation>
                <xs:documentation>
                  An optional parameter that indicates
                  which subset of all possible events
                  is of interest.  The format of this
                  parameter is the same as that of the
                  filter parameter in the NETCONF
                  protocol operations.  If not
                  present, all events not precluded
                  by other parameters will be sent.
                </xs:documentation>
              </xs:annotation>
            </xs:element>
          <xs:element name="startTime" type="xs:dateTime"
            minOccurs="0" >
            <xs:annotation>
              <xs:documentation>
                A parameter used to trigger the replay
                feature indicating that the replay
                should start at the time specified.  If
                start time is not present, this is not a
                replay subscription.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="stopTime" type="xs:dateTime"
            minOccurs="0" >
            <xs:annotation>
              <xs:documentation>
                An optional parameter used with the
                optional replay feature to indicate the
                newest notifications of interest.  If
                stop time is not present, the
                notifications will continue until the
                subscription is terminated.  Must be
                used with startTime.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="streamNameType">
    <xs:annotation>
      <xs:documentation>
        The name of an event stream.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
</xs:schema>