<?xml version="1.0" encoding="utf-8"?>
<!--
	File:    movies.xsd
	Author:  Chriztian Steinmeier
	Created: 2020-12-29
	Description:
		XMLSchema for the movies XML format.
-->
<xsd:schema
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://xmlns.greystate.dk/2020/movies"
	xmlns="http://xmlns.greystate.dk/2020/movies"
>

	<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />

	<!-- Main description -->
	<xsd:annotation>
		<xsd:documentation xml:lang="en">
			<p xmlns="http://www.w3.org/1999/xhtml">
				An XML application for keeping track of the movies I have seen.
			</p>
			<p xmlns="http://www.w3.org/1999/xhtml">
				Typical prefix (if needed) is <var>mov</var> eg. <code>&lt;mov:movies&gt;...&lt;/mov:movie&gt;</code>
			</p>
		</xsd:documentation>
	</xsd:annotation>

	<!-- Root element -->
	<xsd:element name="movies">
		<xsd:complexType>
			<xsd:choice>
				<xsd:element ref="movie" minOccurs="0" maxOccurs="unbounded" />
				<xsd:element ref="series" minOccurs="0" maxOccurs="unbounded" />
				<xsd:element ref="collection" minOccurs="0" maxOccurs="unbounded" />
			</xsd:choice>
			<xsd:attribute ref="xml:lang" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="movie">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Contains a single movie with title and IMDb reference etc.
					The <code>seenthat</code> attribute refers to that movie's ID on a site that might not work anymore.
					But I'm keeping it for now, just in case it comes back online.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="title" minOccurs="1" maxOccurs="unbounded" />
				<xsd:element ref="ticket" minOccurs="0" maxOccurs="unbounded" />
				<xsd:element ref="cinema" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>

			<xsd:attribute name="rating" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:integer">
						<xsd:enumeration value="1" />
						<xsd:enumeration value="2" />
						<xsd:enumeration value="3" />
						<xsd:enumeration value="4" />
						<xsd:enumeration value="5" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>

			<xsd:attribute name="imdb" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:pattern value="tt[0-9]{7,}" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>

			<xsd:attribute name="list" type="xsd:string" use="optional" />
			<xsd:attribute name="year" type="xsd:gYear" use="required" />
			<xsd:attribute name="seenthat" type="xsd:integer" use="optional" />
			<xsd:attribute name="ignore" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="yes" />
						<xsd:enumeration value="no" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute ref="xml:lang" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="series">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Container for a TV series.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="title" minOccurs="1" maxOccurs="unbounded" />
				<xsd:element ref="season" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>
			<xsd:attribute name="year" type="xsd:gYear" />
			<xsd:attribute name="imdb" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:pattern value="tt[0-9]{7,}" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="collection">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Container for a collection of movies (e.g. movies that are part of a trilogy).
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="movie" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>
			<xsd:attribute name="name" type="xsd:string" use="required" />
			<xsd:attribute ref="xml:lang" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="season">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Container for a list of episodes in a season.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="episode" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>
			<xsd:attribute name="num" type="xsd:positiveInteger" use="required" />
			<xsd:attribute name="episodes" type="xsd:positiveInteger" />
			<xsd:attribute name="year" type="xsd:gYear" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="episode">
	</xsd:element>

	<xsd:element name="title">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					The movie's or the series' title. Use the <code>xml:lang</code> attribute to state the language if not english.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:simpleContent>
				<xsd:extension base="xsd:string">
					<xsd:attribute name="label" use="optional">
						<xsd:simpleType>
							<xsd:restriction base="xsd:string">
								<xsd:enumeration value="original" />
								<xsd:enumeration value="alternate" />
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:attribute>
					<xsd:attribute ref="xml:lang" />
				</xsd:extension>
			</xsd:simpleContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="ticket">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					If I have the actual ticket from the cinema, this refers to it by date, place and country.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:attribute name="date" type="xsd:date" use="optional" />
			<xsd:attribute name="place" type="xsd:string" use="optional" />
			<xsd:attribute name="country" type="xsd:string" use="optional" />
			<xsd:attribute name="note" type="xsd:string" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="cinema">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					If I saw this the cinema, this refers to it by date, place and country and maybe the ticket.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:attribute name="date" type="xsd:date" use="optional" />
			<xsd:attribute name="place" type="xsd:string" use="optional" />
			<xsd:attribute name="country" type="xsd:string" use="optional" />
			<xsd:attribute name="note" type="xsd:string" use="optional" />
		</xsd:complexType>
	</xsd:element>

</xsd:schema>
