<?xml version="1.0" encoding="UTF-8"?>
<!-- 
BBC Subtitle Schema V1.0
Last-edited: 2016-04-14 (to permit use of ebutts:linePadding)
Copyright BBC 2016
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.bbc.co.uk/ns/bbctt" xmlns:bbctt="http://www.bbc.co.uk/ns/bbctt" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:tt="http://www.w3.org/ns/ttml" xmlns:ebuttdt="urn:ebu:tt:datatypes">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
  <xs:import namespace="http://www.w3.org/ns/ttml#metadata" schemaLocation="ebu-tt-v1.0-lp-xml-schema/metadata.xsd"/>
  <xs:import namespace="urn:ebu:tt:datatypes" schemaLocation="ebu-tt-v1.0-lp-xml-schema/ebutt_datatypes.xsd"/> 

  <xs:annotation>
      <xs:documentation>
The BBC metadata element additional document level metadata.
       </xs:documentation> 
  </xs:annotation>
  <xs:element name="metadata">
    <xs:complexType>
      <xs:sequence>
        <!-- Mandatory -->
        <xs:element ref="bbctt:schemaVersion"/>       
        <xs:element ref="bbctt:timedTextType"/>
        <xs:element ref="bbctt:timecodeType"/>
        <!-- For programmes with ids -->
        <xs:element minOccurs="0" maxOccurs="1" ref="bbctt:programmeId"/> <!-- minOccurs=0 for live? -->
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:otherId"/>
        <!-- Live only -->
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:houseStyle"/>
        <!-- Live only - allow multiple services -->
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:recordedLiveService"/>
        <!-- Audio Description only -->
        <xs:element minOccurs="0" maxOccurs="1" ref="bbctt:OriginalADVoicer"/>
        <!-- Generic -->
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:div"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="schemaVersion">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="v1.0"/>
        </xs:restriction>
      </xs:simpleType>   
  </xs:element>
  <xs:element name="timedTextType">
    <xs:simpleType>
      <xs:restriction base="xs:NCName">
        <xs:enumeration value="preRecorded"/>
        <xs:enumeration value="audioDescription"/>
        <xs:enumeration value="recordedLive"/>
        <xs:enumeration value="editedLive"/>
      </xs:restriction>
    </xs:simpleType>   
  </xs:element>
  <xs:element name="timecodeType">
    <xs:simpleType>
      <xs:restriction base="xs:NCName">
        <xs:enumeration value="programme"/>
        <xs:enumeration value="timeOfDay"/>
      </xs:restriction>
    </xs:simpleType>   
  </xs:element>
  <xs:element name="programmeId" type="xs:string"/>
  <xs:element name="otherId">
    <xs:complexType mixed="true">
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="OriginalADVoicer" type="xs:string"/>
  <xs:element name="houseStyle">
    <xs:complexType mixed="true">
      <xs:attribute name="owner" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="recordedLiveService">
    <xs:complexType mixed="true">
      <xs:attribute name="finish" use="required" type="xs:dateTime"/>
      <xs:attribute name="start" use="required" type="xs:dateTime"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="div">
    <xs:complexType >
      <xs:all>
        <!-- Include any that are applicable -->
        <xs:element minOccurs="0" maxOccurs="1" ref="bbctt:systemInfo"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:chapter"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:item"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:event"/>
      </xs:all>
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="chapter">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" ref="bbctt:item"/>
      </xs:sequence>
      <xs:attribute ref="xml:id" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="systemInfo" type="xs:string"/> <!-- String that describes the system that generated this part of this file -->
  <xs:element name="item">
    <xs:complexType>
      <xs:sequence>
        <!-- Use identifiers to tie the item to other systems -->
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:itemId"/>
        <xs:element minOccurs="0" maxOccurs="1" ref="bbctt:title"/>
        <xs:element minOccurs="0" maxOccurs="1" ref="bbctt:associatedFile"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:p"/>
      </xs:sequence>
      <xs:attribute name="begin" type="ebuttdt:timingType"/>
      <xs:attribute name="end" type="ebuttdt:timingType"/>
      <xs:attribute ref="xml:id" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="title" type="xs:string"/>
  <xs:element name="p">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="bbctt:span"/>
      </xs:sequence>
      <!-- values for ttm:role are all those in the TTML spec and others specified in the accompanying documentation -->
      <xs:attribute ref="ttm:role"/>
      <xs:attribute ref="ttm:agent"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="span">
    <xs:complexType mixed="true">
      <xs:attribute ref="ttm:role"/>
      <xs:attribute ref="ttm:agent"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="event">
    <xs:complexType>
      <xs:attribute name="begin" use="required" type="ebuttdt:timingType"/>
      <xs:attribute name="end" type="ebuttdt:timingType"/> <!-- Mandatory for AD fades -->
      <xs:attribute name="endLevel" type="xs:integer"/> <!-- Mandatory for AD fades -->
      <xs:attribute name="id" type="xs:NCName"/>
      <xs:attribute name="pan" type="xs:integer"/>  <!-- Mandatory for AD fades -->
      <xs:attribute name="type" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="itemId">
    <xs:complexType mixed="true">
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="associatedFile">
    <xs:complexType mixed="true">
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
</xs:schema>