<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns="http://www.cablelabs.com/namespaces/safi/xsd/com/I01"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.cablelabs.com/namespaces/safi/xsd/com/I01"
    elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
    <xs:annotation>
        <xs:documentation> Revisions from CommonTypes to CLP-SP-AA-COM-D02-090505.xsd in
            doc/ComSchemaChanges_D01_to_D02.doc </xs:documentation>
    </xs:annotation>
    <!-- Simple types -->
    <xs:simpleType name="EpsidType">
        <xs:annotation>
            <xs:documentation> Enhancement sequence number within a Programmed Element. These
                sequence numbers are assigned to message-addressable nodes in the campaign
                description associated with UUIDs and ETypes. The UUID+EPSID can be used to locate
                the node and its ETYPE allows further navigation. Limited to 2 binary bytes.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="65535"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="EventIDType">
        <xs:annotation>
            <xs:documentation>EventID uniquely identifies each component or event in the application
                such as overlay, poll question, RFI, etc..</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="nonEmptyStringType">
        <xs:annotation>
            <xs:documentation> This is an xs:string restricted to have some actual content
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="nonNegativeIntType">
        <xs:annotation>
            <xs:documentation> This is an xs:int restricted to zero or positive content
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PeidType">
        <xs:annotation>
            <xs:documentation>Programmed Element ID type. Initially this is a GUID represented in
                RFC 4122 Base64-URL form (so 16 bytes convert to a 22 byte string). This might use a
                more terse form, but some namespace resolution is needed first.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:length value="22"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PositiveIntType">
        <xs:annotation>
            <xs:documentation> This is an xs:int restricted to  positive content
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:int">
            <xs:minInclusive value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:attributeGroup name="RelativeTimeAttributeGroup">
        <xs:annotation>
            <xs:documentation>Attribute set that defines some instant, or interval starting at some
                instant. The instant is offset from some event, usually start of flight (as
                xs:duration), and the interval is a duration after the offset.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="offset" type="xs:duration" use="required"/>
        <xs:attribute name="interval" type="xs:duration" use="optional"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="OptionalRelativeTimeAttributeGroup">
        <xs:annotation>
            <xs:documentation>Attribute set that may define some instant, or interval starting at
                some instant, but may also be empty. The instant is offset from some event, usually
                start of flight (as xs:duration), and the interval is a duration after the offset.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="offset" type="xs:duration" use="optional"/>
        <xs:attribute name="interval" type="xs:duration" use="optional"/>
    </xs:attributeGroup>
    <xs:simpleType name="SyscodeType">
        <xs:annotation>
            <xs:documentation>A syscode is a unique human-readable identifier that tends to
                represent an insertion point (ex. splicer). These system level syscodes are at the
                MSO level within a given market. Larger network areas are represented by a syscode
                that is itself composed of syscodes.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="4"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="UuidUrlType">
        <xs:annotation>
            <xs:documentation>UUID is a 16 byte integer, encoded using RFC 4122 Base64-URL form, so
                encodes to ceiling((bytes)/3)*4 = 24 Base64 bytes less padding, so 22 total. It
                would be about 43 decimal, 32 hex digits.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:length value="22"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ZipcodeType">
        <xs:restriction base="xs:string">
            <xs:pattern value="(\d{5}-\d{4})|(\d{5})"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="UserInputType">
        <xs:annotation>
            <xs:documentation> UserInput is a single character used to store a user's selection to a
                poll, RFI, etc.. This element is optional as it will not be included in messages
                representing Service Metric updates.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:length value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ParametersType">
        <xs:annotation>
            <xs:documentation> Parameters is an optional string block used to pass other relevant
                data</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string"/>
    </xs:simpleType>
    <xs:simpleType name="PhoneNumberType">
        <xs:annotation>
            <xs:documentation> Human-readable contact phone, so may have extension, etc. Not
                expected to be machine processable </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="25"/>
        </xs:restriction>
    </xs:simpleType>

    <!-- Complex types -->
    <xs:complexType name="VersionType">
        <xs:annotation>
            <xs:documentation>Major version provides the macro versioning number for each interface.
                Versions containing the same major version should provide backwards compatibility.
                The MinSchemaVersion should reffer to a MajorVersion number.</xs:documentation>

            <xs:documentation>MinorVersion allows incremential and backwards compatible updates to
                independently versioned.</xs:documentation>

            <xs:documentation>Lowest compatible schema version number (assumes all forward
                compatible within MajorVersion) A document with a minSchemaVersion of 2 is
                compatible with any processor implementing schema version 2 or greater, but not with
                a processor implementing schema 1.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="MajorVersion" type="PositiveIntType" fixed="1"/>
        <xs:attribute name="MinorVersion" type="nonNegativeIntType" fixed="0"/>
        <xs:attribute name="MinSchemaVersion" type="PositiveIntType" fixed="1"/>
    </xs:complexType>
    <xs:complexType name="ExtType">
        <xs:annotation>
            <xs:documentation>Extensibility - elements from any namespace.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:anyAttribute namespace="##any" processContents="lax"/>
    </xs:complexType>


    <xs:complexType name="GeographicCodeType">
        <xs:annotation>
            <xs:documentation>GeographicCode is an identifier used to denote the location of the
                device/unit. This could be zipcode or syscode.</xs:documentation>
        </xs:annotation>
        <xs:choice>
            <xs:element name="Syscode" type="SyscodeType"/>
            <xs:element name="Zipcode" type="ZipcodeType"/>
        </xs:choice>
    </xs:complexType>
    <!-- SCTE-130-2_2008 program type -->
    <xs:complexType name="ProgramType" mixed="true">
        <xs:complexContent>
            <xs:restriction base="xs:anyType">
                <xs:attribute name="uniqueProgramID" type="nonNegativeIntType" use="optional">
                    <xs:annotation>
                        <xs:documentation>Unique program identifier.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="referenceDateTime" type="xs:dateTime" use="optional">
                    <xs:annotation>
                        <xs:documentation>Reference date and time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:anyAttribute namespace="##any" processContents="lax"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>


    <xs:complexType name="AcknowledgementMessageType">
        <xs:sequence>
            <xs:element name="Ack" type="xs:boolean"/>
        </xs:sequence>
        <xs:attribute name="TransmissionId" type="xs:string"/>
    </xs:complexType>

    <!--SCTE 35 Segmentation UPID element as of SCTE130-2_2008-->
    <xs:complexType name="Scte35SegmentationUpidType">
        <xs:simpleContent>
            <xs:extension base="xs:hexBinary">
                <xs:attribute name="type" type="xs:unsignedByte" use="required">
                    <xs:annotation>
                        <xs:documentation>A value from SCTE 35 Table 8-6 identifying the information
                            format.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="length" type="xs:unsignedByte" use="optional">
                    <xs:annotation>
                        <xs:documentation>The information length in bytes. Limits may be applied as
                            per SCTE 35 Table 8-6.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="eventID" type="xs:unsignedInt" use="optional">
                    <xs:annotation>
                        <xs:documentation>A 32-bit unique segmentation event
                            identifier.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="typeID" type="xs:unsignedByte" use="optional">
                    <xs:annotation>
                        <xs:documentation>The segmentation type as specified by SCTE 35 Table
                            8-7.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="segmentNum" type="xs:unsignedByte" use="optional">
                    <xs:annotation>
                        <xs:documentation>Identification of a specific segment within a segmentation
                            upid.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="segmentsExpected" type="xs:unsignedByte" use="optional">
                    <xs:annotation>
                        <xs:documentation>Expected number of individual segments within the
                            segmentation upid.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="referenceDateTime" type="xs:dateTime" use="optional">
                    <xs:annotation>
                        <xs:documentation>Contextual reference date and time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:anyAttribute namespace="##any" processContents="lax"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <!--Tracking element-->
    <xs:complexType name="TrackingType">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:anyAttribute namespace="##any" processContents="lax"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="TimestampType">
        <xs:sequence>
            <xs:element name="StartTime" type="xs:dateTime"/>
        </xs:sequence>
        <xs:attributeGroup ref="RelativeTimeAttributeGroup"/>
    </xs:complexType>


    <xs:complexType name="TimeRangeType">
        <xs:annotation>
            <xs:documentation> Defines an absolute time range. </xs:documentation>
        </xs:annotation>
        <xs:attribute name="starttime" type="xs:dateTime" use="required"/>
        <xs:attribute name="endtime" type="xs:dateTime" use="required"/>
    </xs:complexType>


    <xs:complexType name="FaultType">
        <xs:sequence>
            <xs:element name="reason" type="xs:string"/>
        </xs:sequence>
        <xs:attribute name="code" type="xs:int" use="optional"/>
    </xs:complexType>

    <!-- Groups -->
    <xs:group name="PackageIDGroup">
        <xs:sequence>
            <xs:element name="PEID" type="PeidType"/>
            <xs:element name="EPSID" type="EpsidType"/>
            <xs:element name="EventID" type="EventIDType" minOccurs="0"/>
        </xs:sequence>
    </xs:group>
</xs:schema>

