<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/export"
	xmlns:tns="http://www.example.org/export" elementFormDefault="qualified"
	version="0.1">

	<element name="bioDataExchange" type="tns:BioDataExchangeType">
	</element>

	<simpleType name="UUIDType">
		<annotation>
			<documentation>Type for holding the string representation of a UUID
				or GUID
			</documentation>
		</annotation>
		<restriction base="string">
			<pattern
				value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" />
		</restriction>
	</simpleType>

	<simpleType name="VagueDataTypesType">
		<annotation>
			<documentation>Types of a vague date</documentation>
		</annotation>
		<restriction base="string">
			<enumeration value="D">
				<annotation>
					<documentation>A specific day. Pattern: "yyyy-mm-dd"
					</documentation>
				</annotation>
			</enumeration>
			<enumeration value="-Y">
				<annotation>
					<documentation>Till a year. Pattern: "-yyyy"</documentation>
				</annotation>
			</enumeration>
			<enumeration value="Y">
				<annotation>
					<documentation>A year. Pattern: "yyyy"</documentation>
				</annotation>
			</enumeration>
			<enumeration value="O">
				<annotation>
					<documentation>A month in a year. Pattern: "mm-yyyy"</documentation>
				</annotation>
			</enumeration>
			<enumeration value="DD">
				<annotation>
					<documentation>A period between tow days. Pattern "yyyy-mm-dd to yyyy-mm-dd"
					</documentation>
				</annotation>
			</enumeration>
		</restriction>
	</simpleType>

	<complexType name="VagueDateType">
		<annotation>
			<documentation>Type for holding a vague date information. Supported
				are a specific day, a month in a year, a year or a period of time
				between to days.
			</documentation>
		</annotation>
		<simpleContent>
			<extension base="string">
				<attribute name="type" use="required" type="tns:VagueDataTypesType" />
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="SampleType">
		<annotation>
			<documentation>A sample is the representation of a time, and area. A
				sample also contains on more occurrences.
			</documentation>
		</annotation>
		<all>
			<element name="date" type="tns:VagueDateType" minOccurs="1"
				maxOccurs="1" />
			<element name="occurrences" type="tns:OccurrencesType"
				maxOccurs="1" minOccurs="1" />
			<element name="uuid" type="tns:UUIDType" minOccurs="1"
				maxOccurs="1" />
			<element name="comment" type="string" minOccurs="0"
				maxOccurs="1" />
			<element name="recorders" type="IDREFS" minOccurs="0" />
			<element name="position" type="tns:PositionType" minOccurs="1"
				maxOccurs="1" />
		</all>
	</complexType>

	<complexType name="OccurrenceType">
		<annotation>
			<documentation>A occurrence represents a species found in a sample.
			</documentation>
		</annotation>
		<all>
			<element name="uuid" type="tns:UUIDType" />
			<element name="name" type="string" maxOccurs="1" minOccurs="0" />
			<element name="determiners" type="IDREFS" minOccurs="0" />
			<element name="comment" type="string" minOccurs="0" />
			<element name="taxonRefList" type="string" minOccurs="1" />
			<element name="taxonRef" type="string" minOccurs="1" />
		</all>
	</complexType>

	<complexType name="BioDataExchangeType">
		<sequence>
			<element name="metaData" type="tns:MetaDataType" maxOccurs="1"
				minOccurs="1"></element>
			<element name="samples" type="tns:SamplesType" maxOccurs="1"
				minOccurs="1"></element>
		</sequence>
	</complexType>

	<complexType name="SamplesType">
		<sequence>
			<element name="sample" type="tns:SampleType" maxOccurs="unbounded"
				minOccurs="1"></element>
		</sequence>
	</complexType>

	<complexType name="OccurrencesType">
		<sequence>
			<element name="occurrence" type="tns:OccurrenceType"
				maxOccurs="unbounded" minOccurs="1"></element>
		</sequence>
	</complexType>
	<complexType name="MetaDataType">
		<annotation>
			<documentation>
				Holding the meta data of a exchange xml.
				<p />
				This can be processed before the samples, so that all the meta data
				is
				in the target system before the actual data is processed.
			</documentation>
		</annotation>
		<all>
			<element name="sourceSystem" type="string">
				<annotation>
					<documentation>The id of the source system which produced the xml.
					</documentation>
				</annotation>
			</element>
			<element name="creationDate" type="dateTime">
				<annotation>
					<documentation>The time when the xml was created.
					</documentation>
				</annotation>
			</element>
			<element name="persons" type="tns:PersonsType">
				<annotation>
					<documentation>Persons referenced in this document.
					</documentation>
				</annotation>
			</element>
		</all>
	</complexType>

	<complexType name="PersonsType">
		<sequence>
			<element name="person" type="tns:PersonType" maxOccurs="unbounded"
				minOccurs="0">
			</element>
		</sequence>
	</complexType>

	<complexType name="PersonType">
		<all>
			<element name="id" type="ID" />
			<element name="firstName" type="string" minOccurs="0"></element>
			<element name="lastName" type="string"></element>
			<element name="birthday" type="date" minOccurs="0"></element>
			<element name="academicDegree" type="string" minOccurs="0"></element>
		</all>
	</complexType>

	<complexType name="PositionType">
		<all>
			<element name="srefSystem" type="string" maxOccurs="1"
				minOccurs="0">
				<annotation>
					<documentation>The spatial reference system used for the position.
						EPSG-xxxxx for EPSG codes, or DE-MTB for german
						"Messtischblattquadranten"
					</documentation>
				</annotation>
			</element>
			<element name="wkt" type="string" maxOccurs="1" minOccurs="0">
			</element>
			<element name="precision" type="int" minOccurs="0" />
			<element name="mtb" minOccurs="0" maxOccurs="1">
				<simpleType>
					<restriction base="string">
						<pattern value="[0-9]{4}(/[1-4])?" />
					</restriction>
				</simpleType>
			</element>
			<element name="description" minOccurs="0" type="string" />
		</all>
	</complexType>
</schema>