<?xml version="1.0" encoding="UTF-8"?>
<schema 
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:tpt="http://www.atsc.org/XMLSchemas/iss-tpt-1"
    xmlns:sg="http://www.atsc.org/XMLSchemas/nrt-sg-2"
    targetNamespace="http://www.atsc.org/XMLSchemas/iss-tpt-1"
    elementFormDefault="qualified"
    version="1.0">
    <import namespace="http://www.atsc.org/XMLSchemas/nrt-sg-2" schemaLocation="SG2.0.xsd"/>
    <annotation>
        <documentation source="http://www.atsc.org/cms/standards/cs_documents/A105-CS.zip"> 
            ATSC Interactive Services Standard (ISS) TPT-related schema 
            Version: 1.0 
            Date: 12/12/2013 
            Namespace: http://www.atsc.org/XMLSchemas/iss-tpt-1 
            Information about the use of this schema can be found in ATSC standard A/105-2013. 
            This schema defines several XML elements: 
            (1) An XML element named TPT that represents the TDO ParametersTable
            (2) An XML element named AMT that represents the Activation Messages Table
            (3) An XML element named UrlList that represents a list of URLs useful to receivers. 
        </documentation>
    </annotation>

    <!-- GLOBAL ELEMENTS -->
    <annotation>
        <documentation> TPT -- TDO Parameters Table -- contains properties of TDOs used in a
            segment, including properties of the events targeting the TDOs </documentation>
    </annotation>
    <element name="TPT" type="tpt:TptType"/>

    <annotation>
        <documentation> AMT -- Activation Messages Table element -- contains list of activation
            messages for a segment </documentation>
    </annotation>
    <element name="AMT" type="tpt:AmtType"/>

    <annotation>
        <documentation> UrlList-- URL List element -- contains list of URLs of interest to receivers
        </documentation>
    </annotation>
    <element name="UrlList" type="tpt:UrlListType"/>

    <!-- TYPE DEFINITIONS -->
    <complexType name="TptType">
        <sequence>
            <element name="Capabilities" type="sg:CapabilitiesType" minOccurs="0"/>
            <element name="LiveTrigger" type="tpt:LiveTriggerType" minOccurs="0"/>
            <element name="TDO" type="tpt:TDOType" maxOccurs="unbounded"/>
        </sequence>
        <attribute name="majorProtocolVersion" type="tpt:nibble" use="optional" default="1"/>
        <attribute name="minorProtocolVersion" type="tpt:nibble" use="optional" default="0"/>
        <attribute name="id" type="anyURI" use="required"/>
        <attribute name="tptVersion" type="unsignedByte" use="required"/>
        <attribute name="expireDate" type="dateTime" use="optional"/>
        <attribute name="updatingTime" type="unsignedShort" use="optional"/>
        <attribute name="serviceID" type="unsignedShort" use="optional"/>
        <attribute name="baseURL" type="anyURI" use="optional"/>
    </complexType>

    <complexType name="AppBoundaryType">
        <sequence>
            <element name="OriginURL" type="anyURI" maxOccurs="unbounded"/>
        </sequence>
    </complexType>

    <complexType name="LiveTriggerType">
        <attribute name="URL" type="anyURI" use="required"/>
        <attribute name="pollPeriod" type="unsignedByte" use="optional"/>
    </complexType>

    <complexType name="TDOType">
        <sequence>
            <element name="URL" maxOccurs="unbounded">
                <complexType>
                    <simpleContent>
                        <extension base="anyURI">
                            <attribute name="entry" type="boolean" use="optional" default="false"/>
                        </extension>
                    </simpleContent>
                </complexType>
            </element>
            <element name="Capabilities" type="sg:CapabilitiesType" minOccurs="0"/>
            <element name="ApplicationBoundary" type="tpt:AppBoundaryType" minOccurs="0"/>
            <element name="ContentItem" type="tpt:ContentItemType" minOccurs="0"
                maxOccurs="unbounded"/>
            <element name="Event" type="tpt:EventType" maxOccurs="unbounded"/>
        </sequence>
        <attribute name="appId" type="unsignedShort" use="required"/>
        <attribute name="appType" type="tpt:nibble" use="optional" default="1"/>
        <attribute name="appName" type="string" use="optional"/>
        <attribute name="globalID" type="anyURI" use="optional"/>
        <attribute name="appVersion" type="unsignedByte" use="optional"/>
        <attribute name="cookieSpace" type="unsignedByte" use="optional" default="0"/>
        <attribute name="frequencyOfUse" type="tpt:nibble" use="optional"/>
        <attribute name="expireDate" type="dateTime" use="optional"/>
        <attribute name="testTDO" type="boolean" use="optional" default="false"/>
        <attribute name="availInternet" type="boolean" use="optional" default="true"/>
        <attribute name="availBroadcast" type="boolean" use="optional" default="true"/>
    </complexType>

    <complexType name="ContentItemType">
        <sequence>
            <element name="URL" maxOccurs="unbounded">
                <complexType>
                    <simpleContent>
                        <extension base="anyURI">
                            <attribute name="entry" type="boolean" use="optional" default="false"/>
                        </extension>
                    </simpleContent>
                </complexType>
            </element>
        </sequence>
        <attribute name="updatesAvail" type="boolean" use="optional" default="false"/>
        <attribute name="pollPeriod" type="unsignedByte" use="optional"/>
        <attribute name="size"  use="optional">
            <simpleType>
                <restriction base="unsignedInt">
                    <maxInclusive value="16777215"/>
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="availInternet" type="boolean" use="optional" default="true"/>
        <attribute name="availBroadcast" type="boolean" use="optional" default="true"/>
    </complexType>

    <complexType name="EventType">
        <sequence>
            <element name="Data" minOccurs="0" maxOccurs="unbounded">
                <complexType>
                    <simpleContent>
                        <extension base="base64Binary">
                            <attribute name="dataID" type="unsignedShort" use="required"/>
                        </extension>
                    </simpleContent>
                </complexType>
            </element>
        </sequence>
        <attribute name="eventID" type="unsignedShort" use="required"/>
        <attribute name="action" type="string" use="required"/>
        <attribute name="destination" type="unsignedByte" use="optional"/>
        <attribute name="diffusion" type="unsignedByte" use="optional"/>
    </complexType>

    <complexType name="AmtType">
        <sequence>
            <element name="Activation" maxOccurs="unbounded">
                <complexType>
                    <attribute name="targetTDO" type="unsignedShort" use="required"/>
                    <attribute name="targetEvent" type="unsignedShort" use="required"/>
                    <attribute name="targetData" type="unsignedShort"/>
                    <attribute name="startTime" type="tpt:mtType" use="required"/>
                    <attribute name="endtime" type="tpt:mtType" use="optional"/>
                </complexType>
            </element>
        </sequence>
        <attribute name="majorProtocolVersion" type="tpt:nibble" use="optional" default="1"/>
        <attribute name="minorProtocolVersion" type="tpt:nibble" use="optional" default="0"/>
        <attribute name="segmentId" type="anyURI" use="required"/>
        <attribute name="beginMT" type="tpt:mtType" use="optional"/>
    </complexType>

    <complexType name="UrlListType">
        <sequence>
            <element name="TptUrl" type="anyURI" minOccurs="0" maxOccurs="unbounded"/>
            <element name="NrtSignalingUrl" type="anyURI" minOccurs="0"/>
            <element name="UrsUrl" type="anyURI" minOccurs="0"/>
            <element name="PdiUrl" type="anyURI" minOccurs="0"/>
        </sequence>
    </complexType>

    <simpleType name="mtType">
        <restriction base="hexBinary">
            <maxLength value="4"/>
        </restriction>
    </simpleType>

    <simpleType name="nibble">
        <restriction base="unsignedByte">
            <maxInclusive value="15"/>
        </restriction>
    </simpleType>


</schema>
