<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="https://www.isan.org/ISAN/isan" targetNamespace="https://www.isan.org/ISAN/isan" elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/XML.xsd"/>

	<xs:annotation>
		<xs:documentation source="ISAN International Agency" xml:lang="ENG">
		- ISAN and ISAN Version XML schema (ISO 15706-1:2002 and ISO 15706-2:2007) version 3.0 - 2021-10-06
		</xs:documentation>
	</xs:annotation>

	<xs:simpleType name="rootType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="episodeOrPartType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[\dA-Fa-f]{4}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="versionType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[\dA-Fa-f]{4}-[\dA-Fa-f]{4}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="checkType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[\dA-Za-z]{1}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:attributeGroup name="isanGroup">
		<xs:attribute name="root" type="rootType" use="required"/>
		<xs:attribute name="episodeOrPart" type="episodeOrPartType" use="optional"/>
		<xs:attribute name="check1" type="checkType" use="optional"/>
		<xs:attribute name="version" type="versionType" use="optional"/>
		<xs:attribute name="check2" type="checkType" use="optional"/>
	</xs:attributeGroup>

	<xs:complexType name="isanType">
		<xs:attributeGroup ref="isanGroup"/>
	</xs:complexType>

<xs:element name="ISAN" type="isanType"/>

<!--
	xISAN: Extended ISAN schema by adding the ISAN string as element value
-->
	<xs:simpleType name="IsanStringType">
		<xs:annotation>
			<xs:documentation>ISAN representation as a sting </xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="ISAN [\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-Z]-[\dA-F]{4}-[\dA-F]{4}-[\dA-Z]"/>
			<xs:pattern value="[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-Z]-[\dA-F]{4}-[\dA-F]{4}-[\dA-Z]"/>
			<xs:pattern value="[\dA-F]{24}"/>

			<xs:pattern value="ISAN [\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}(-[\dA-Z])?"/>
			<xs:pattern value="[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}(-[\dA-Z])?"/>
			<xs:pattern value="[\dA-F]{16}"/>

			<xs:pattern value="root ISAN [\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}"/>
			<xs:pattern value="ISAN [\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}"/>
			<xs:pattern value="[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}"/>
			<xs:pattern value="[\dA-F]{12}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="xIsanType">
		<xs:annotation>
			<xs:documentation xml:lang="en">
				<xs:H4>Description</xs:H4> ISAN represention in the ISAN API </xs:documentation>
		</xs:annotation>
		<xs:simpleContent>
			<xs:extension base="IsanStringType">
				<xs:attributeGroup ref="isanGroup"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	
	<xs:element name="xISAN" type="xIsanType"/>

</xs:schema>