<?xml version="1.0" encoding="utf-8" ?>
<!--
W3C Channel Definition Format XML Schema
Copyright (c) 2021 ~lucidiot

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

This file was derived from the Channel Definition Format specification
at <https://www.w3.org/TR/NOTE-CDFsubmit.html>.
-->
<xs:schema targetNamespace="https://www.w3.org/TR/NOTE-CDFsubmit"
                  version="1.0" 
                  elementFormDefault="qualified"
                  xmlns="https://www.w3.org/TR/NOTE-CDFsubmit"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="boolean">
    <xs:restriction base="xs:string">
      <xs:enumeration value="YES" />
      <xs:enumeration value="NO" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="priority">
    <xs:restriction base="xs:string">
      <xs:enumeration value="HI" />
      <xs:enumeration value="NORMAL" />
      <xs:enumeration value="LOW" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="precache">
    <xs:restriction base="xs:string">
      <xs:enumeration value="DEFAULT">
        <xs:annotation>
          <xs:documentation>
            Whatever the user has as default.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="YES">
        <xs:annotation>
          <xs:documentation>
            Do retrieve contents into the cache.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="NO">
        <xs:annotation>
          <xs:documentation>
            Do not retrieve contents into the cache.
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="userScheduleValue">
    <xs:restriction base="xs:string">
      <xs:enumeration value="DAILY" />
      <xs:enumeration value="WEEKLY" />
      <xs:enumeration value="HOURLY" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="logoType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="BIG" />
      <xs:enumeration value="WIDE" />
      <xs:enumeration value="SMALL" />
      <xs:enumeration value="REGULAR" />
    </xs:restriction>
  </xs:simpleType>
  
  <xs:complexType name="common" abstract="true">
    <xs:sequence>
      <xs:element name="LastMod" type="LastMod" minOccurs="0" />
      <xs:element name="Title" type="Title" minOccurs="0" />
      <xs:element name="Abstract" type="Abstract" minOccurs="0" />
      <xs:element name="Author" type="Author" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Publisher" type="Publisher" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Copyright" type="Copyright" minOccurs="0" />
      <xs:element name="PublicationDate" type="PublicationDate" minOccurs="0" />
      <xs:element name="Logo" type="Logo" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Keywords" type="Keywords" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Category" type="Category" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Ratings" type="Ratings" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="Schedule" type="Schedule" minOccurs="0" />
      <xs:element name="UserSchedule" type="UserSchedule" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="LastMod">
    <xs:annotation>
      <xs:documentation>
        Last modified date for this web page
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:dateTime" use="required" />
  </xs:complexType>

  <xs:complexType name="Title">
    <xs:annotation>
      <xs:documentation>
        Title
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Abstract">
    <xs:annotation>
      <xs:documentation>
        Short description summarizing the article (200 characters or less recommended)
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Author">
    <xs:annotation>
      <xs:documentation>
        Author
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Publisher">
    <xs:annotation>
      <xs:documentation>
        Publisher
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Copyright">
    <xs:annotation>
      <xs:documentation>
        Copyright
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="PublicationDate">
    <xs:annotation>
      <xs:documentation>
        Publication Date
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Keywords">
    <xs:annotation>
      <xs:documentation>
        Comma delimited keywords that match this channel
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Category">
    <xs:annotation>
      <xs:documentation>
        A category to which this web page belongs in. The string value is a URI to a CategoryDef element.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="#.*" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>
  
  <xs:complexType name="Ratings">
    <xs:annotation>
      <xs:documentation>
        Rating of the channel by one or more ratings services. (String found in PICS label meta tag.)
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" use="required" />
  </xs:complexType>
  
  <xs:complexType name="Channel">
    <xs:annotation>
      <xs:documentation>
        Defines a channel.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="common">
        <xs:sequence>
          <xs:element name="Channel" type="Channel" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="Item" type="Item" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="IntroURI" type="IntroURI" minOccurs="0" />
          <xs:element name="Authorization" type="Authorization" minOccurs="0" />
          <xs:element name="MinStorage" type="MinStorage" minOccurs="0" />
          <xs:element name="Tracking" type="Tracking" minOccurs="0" />
        </xs:sequence>
        <xs:attribute name="HREF" type="xs:anyURI" use="optional">
          <xs:annotation>
            <xs:documentation>
              URI for the next updated version of this channel
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="IsClonable" type="boolean" use="optional" default="NO">
          <xs:annotation>
            <xs:documentation>
              Can channel be copied or moved within the channel changer hierarchy
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="IntroURI">
    <xs:annotation>
      <xs:documentation>
        URI to introductory web page for channel. Can provide general and setup information
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:anyURI" use="required" />
  </xs:complexType>

  <xs:complexType name="Authorization">
    <xs:annotation>
      <xs:documentation>
        Certification of executable content downloadable by this channel ("Authenticode for channels")
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:anyURI" use="required" />
  </xs:complexType>

  <xs:complexType name="MinStorage">
    <xs:annotation>
      <xs:documentation>
        Minimum storage size required, in kilobytes
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:nonNegativeInteger" use="optional" default="0" />
  </xs:complexType>
  
  <xs:complexType name="Item">
    <xs:annotation>
      <xs:documentation>
        Defines an item of a channel, a unit of information for the user, usually corresponding to a web page.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="common">
        <xs:sequence>
          <xs:element name="Usage" type="Usage" minOccurs="0" />
        </xs:sequence>
        <xs:attribute name="HREF" type="xs:anyURI" use="required">
          <xs:annotation>
            <xs:documentation>
              URI of article contents
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="MIMEType" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>
              MIME Type of article contents
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="IsVisible" type="boolean" use="optional" default="YES">
          <xs:annotation>
            <xs:documentation>
              This item should be visible to the user.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Priority" type="priority" use="optional" default="NORMAL">
          <xs:annotation>
            <xs:documentation>
              Priority of this item
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Precache" type="precache" use="optional" default="DEFAULT">
          <xs:annotation>
            <xs:documentation>
              Publisher recommended download behavior.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="Usage">
    <xs:annotation>
      <xs:documentation>
        Start tag should have VALUE=usage where usage indicates how this item should be used. Children elements can specify more parameters.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:any minOccurs="0" />
    </xs:sequence>
    <xs:attribute name="VALUE" type="xs:string" use="optional" />
  </xs:complexType>
  
  <xs:complexType name="UserSchedule">
    <xs:annotation>
      <xs:documentation>
        Specifies a client-side user-defined schedule.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="userScheduleValue" use="optional">
      <xs:annotation>
        <xs:documentation>
          ID/name for predefined/client defined schedule
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="StartDate">
    <xs:annotation>
      <xs:documentation>
        This is the day upon which the schedule will start to apply.
        By default, the schedule starts immediately.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:dateTime" use="required" />
  </xs:complexType>

  <xs:complexType name="EndDate">
    <xs:annotation>
      <xs:documentation>
        This is the day upon which the schedule will start to apply.
        By default, the schedule never ends.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:dateTime" use="required" />
  </xs:complexType>

  <xs:complexType name="baseTime" abstract="true">
    <xs:attribute name="DAY" type="xs:nonNegativeInteger" default="0" />
    <xs:attribute name="HOUR" type="xs:nonNegativeInteger" default="0" />
    <xs:attribute name="MIN" type="xs:nonNegativeInteger" default="0" />
    <xs:attribute name="SEC" type="xs:nonNegativeInteger" default="0" />
  </xs:complexType>

  <xs:complexType name="IntervalTime">
    <xs:complexContent>
      <xs:extension base="baseTime">
        <xs:annotation>
          <xs:documentation>
            The interval of time that the schedule should repeat over.
            By default, it only performs the schedule once (infinity).
          </xs:documentation>
        </xs:annotation>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="EarliestTime">
    <xs:complexContent>
      <xs:extension base="baseTime">
        <xs:annotation>
          <xs:documentation>
            Earliest time during the schedule interval that the schedule applies to.
            By default, the schedule will be performed at the beginning of the interval.
          </xs:documentation>
        </xs:annotation>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="LatestTime">
    <xs:complexContent>
      <xs:extension base="baseTime">
        <xs:annotation>
          <xs:documentation>
            Latest time during the schedule interval that the schedule applied to. If it is not equal to EarliestTime, then the time is randomly chosen in range.
            By default, the schedule will be performed at the beginning of the interval.
          </xs:documentation>
        </xs:annotation>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="Schedule">
    <xs:annotation>
      <xs:documentation>
        Defines a bounded repeating interval of time.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="StartDate" type="StartDate" minOccurs="0" />
      <xs:element name="EndDate" type="EndDate" minOccurs="0" />
      <xs:element name="IntervalTime" type="IntervalTime" minOccurs="0" />
      <xs:element name="EarliestTime" type="EarliestTime" minOccurs="0" />
      <xs:element name="LatestTime" type="LatestTime" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Logo">
    <xs:annotation>
      <xs:documentation>
        Defines an image that can be used to represent a channel or channel item.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="HREF" type="xs:anyURI" use="required">
      <xs:annotation>
        <xs:documentation>
          URL to the image for the logo
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="TYPE" type="logoType" use="optional" default="REGULAR">
      <xs:annotation>
        <xs:documentation>
          String indicating what context image should be used.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="Tracking">
    <xs:annotation>
      <xs:documentation>
        Indicates how a channel can or should support user tracking.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="PostURL" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="PostURL">
    <xs:annotation>
      <xs:documentation>
        The URL to post tracking results to
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="HREF" type="xs:anyURI" use="required" />
  </xs:complexType>

  <xs:complexType name="CategoryDef">
    <xs:annotation>
      <xs:documentation>
        This profile provides a generic container for properties of a category. Item profiles (used by channel and article profiles) can reference to these category elements using the URI "#foo" when ID="foo" is a parameter in the Category tag.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="CategoryName" />
      <xs:element name="Description" type="Description" minOccurs="0" />
      <xs:element name="CategoryDef" type="CategoryDef" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="ID" type="xs:ID" use="optional" />
  </xs:complexType>

  <xs:complexType name="CategoryName">
    <xs:annotation>
      <xs:documentation>
        Name of category
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" />
  </xs:complexType>

  <xs:complexType name="Description">
    <xs:annotation>
      <xs:documentation>
        Textual description of category
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="VALUE" type="xs:string" />
  </xs:complexType>

  <xs:element name="Channel" type="Channel" />
</xs:schema>