<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="https://rss.iris.a2d.tv/ns/media/1.0/"
            xmlns="https://rss.iris.a2d.tv/ns/media/1.0/"
            elementFormDefault="qualified">

  <!-- ===== Common simple types ===== -->
  <xsd:simpleType name="HHMMSS">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{2}:\d{2}:\d{2}"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="OrderStatus">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="RECEIVED"/>
      <xsd:enumeration value="CANCELLED"/>
      <xsd:enumeration value="FULFILLED"/>
    </xsd:restriction>
  </xsd:simpleType>

  <!-- ===== Orders feed elements (iris:*) ===== -->

  <!-- Last modification of the order (ISO-8601 UTC, seconds precision) -->
  <xsd:element name="updatedAt" type="xsd:dateTime"/>

  <!-- Identifier of the target material the finished subtitle belongs to -->
  <xsd:element name="materialId" type="xsd:string"/>

  <!-- Delivery deadline in UTC (ISO-8601) -->
  <xsd:element name="deadline" type="xsd:dateTime"/>

  <!-- Accounting or commissioning cost center / label -->
  <xsd:element name="costLocation" type="xsd:string"/>

  <!-- Target subtitle language (BCP-47) -->
  <xsd:element name="targetLanguageTag" type="xsd:string"/>

  <!-- Desired subtitle format - always a single value, never a list -->
  <xsd:element name="targetSubtitleFormats" type="xsd:string"/>

  <!-- Order lifecycle status -->
  <xsd:element name="status" type="OrderStatus"/>

  <!-- Season run order -->
  <xsd:element name="season" type="xsd:integer"/>

  <!-- Episode run order -->
  <xsd:element name="episode" type="xsd:integer"/>

  <!-- Program duration (HH:MM:SS) -->
  <xsd:element name="duration" type="HHMMSS"/>

  <!-- Title of a single (non-episodic) work -->
  <xsd:element name="title" type="xsd:string"/>

  <!-- Localized/domestic title of a single work -->
  <xsd:element name="domesticTitle" type="xsd:string"/>

  <!-- Production title of a single work -->
  <xsd:element name="productionTitle" type="xsd:string"/>

  <!-- Canonical series title -->
  <xsd:element name="seriesTitle" type="xsd:string"/>

  <!-- Localized/domestic series title -->
  <xsd:element name="seriesDomesticTitle" type="xsd:string"/>

  <!-- Production title of the series -->
  <xsd:element name="seriesProductionTitle" type="xsd:string"/>

  <!-- Episode title -->
  <xsd:element name="episodeTitle" type="xsd:string"/>

  <!-- Localized/domestic episode title -->
  <xsd:element name="episodeDomesticTitle" type="xsd:string"/>

  <!-- Original/source language (BCP-47) -->
  <xsd:element name="sourceLanguage" type="xsd:string"/>

  <!-- ===== Media feed elements (iris:*) ===== -->

  <!-- Burnt-in time code (BITC) proxy video URL. Presigned when the media
       record is created and stored as-is, so it expires ~7 days after pubDate -->
  <xsd:element name="bitc">
    <xsd:complexType>
      <xsd:simpleContent>
        <xsd:extension base="xsd:anyURI">
          <xsd:attribute name="description" type="xsd:string"/>
        </xsd:extension>
      </xsd:simpleContent>
    </xsd:complexType>
  </xsd:element>

  <!-- Upload portal URL for delivering the finished subtitle file. Minted when
       the media record is created and stored as-is, so it expires on its own clock -->
  <xsd:element name="upload">
    <xsd:complexType>
      <xsd:simpleContent>
        <xsd:extension base="xsd:anyURI">
          <xsd:attribute name="description" type="xsd:string"/>
        </xsd:extension>
      </xsd:simpleContent>
    </xsd:complexType>
  </xsd:element>

  <!-- Back-reference to the subtitle order; the identifier is carried in the
       "value" attribute and the element itself is empty -->
  <xsd:element name="guid">
    <xsd:complexType>
      <xsd:attribute name="value" type="xsd:string" use="required"/>
      <xsd:attribute name="description" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

</xsd:schema>
