<?xml version="1.0" encoding="UTF-8"?>

<!--  QuDEx version 3.0
	Final release under the DExT Data Exchange Tools Project
	Please Note: this schema remains in DRAFT status
	
	Changes since version 2.0: for full details please refer to the version release notes

	1) MemoSource made optional
	2) Trailing spaces in RelationName removed
	3) XML segment scope changed to  one range node element with an xpointer expression
	4) Removed segmentHdr and segmentContent Elements 
	5) Removed memoHdr and memoContent Elements
	6) Changed ParamTypeAudio to AudioParamType to match overall naming conventions 
	7) Changed ParamTypeVideo to VideoParamType to match overall naming conventions 
	
	
-->

<xs:schema xmlns="http://www.data-archive.ac.uk/dext/schema/draft"
	targetNamespace="http://www.data-archive.ac.uk/dext/schema/draft"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<!-- Top level element for QuDEx -->
	<xs:element name="qudex" type="QudexType">
		<xs:annotation>
			<xs:documentation> A 'wrapper' for all elements of the QuDEx Schema. 
			</xs:documentation>
		</xs:annotation>
	</xs:element>

	<!-- Standard attribute group -->
	<xs:attributeGroup name="standard-attributes">
		<xs:attribute name="cdate" type="xs:dateTime" use="optional"/>
		<xs:attribute name="mdate" type="xs:dateTime" use="optional"/>
		<xs:attribute name="creator" type="xs:string" use="optional"/>
		<xs:attribute name="label" type="xs:string" use="optional"/>
		<xs:attribute name="displayLabel" type="xs:string" use="optional"/>
		<xs:attribute name="language" type="xs:language" use="optional"/>
	</xs:attributeGroup>

	<!-- Resource attribute group -->
	<xs:attributeGroup name="resource-attributes">
		<xs:attribute name="sequence" type="xs:int" use="optional"/>
		<xs:attribute name="size" type="xs:long" use="optional"/>
		<xs:attribute name="location" type="xs:anyURI" use="required"/>
		<xs:attribute name="locType" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="urn"/>
					<xs:enumeration value="url"/>
					<xs:enumeration value="purl"/>
					<xs:enumeration value="handle"/>
					<xs:enumeration value="doi"/>
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherLocType" type="xs:string" use="optional"/>
		<xs:attribute name="checksumType" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="haval"/>
					<xs:enumeration value="md-5"/>
					<xs:enumeration value="sha-1"/>
					<xs:enumeration value="sha-256"/>
					<xs:enumeration value="sha-384"/>
					<xs:enumeration value="sha-512"/>
					<xs:enumeration value="tiger"/>
					<xs:enumeration value="whirlpool"/>
					<xs:enumeration value="crc32"/>
					<xs:enumeration value="adler32"/>
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherCheckSumType" type="xs:string" use="optional"/>
		<xs:attribute name="checksumValue" type="xs:string" use="optional"/>
		<xs:attribute name="mimeType" type="xs:string" use="optional"/>
		<xs:attribute name="resourceType" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="text"/>
					<xs:enumeration value="audio"/>
					<xs:enumeration value="video"/>
					<xs:enumeration value="image"/>
					<xs:enumeration value="xml"/>
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherResourceType" type="xs:string" use="optional"/>
	</xs:attributeGroup>

	<!-- Qudex type definition-->
	<xs:complexType name="QudexType">
		<xs:annotation>
			<xs:documentation> The root element; a 'wrapper' for all other elements of the QuDEx Schema. 
				Each top level element in QuDEx is defined as a ‘collection’.
				Child elements: resourceCollection, segmentCollection, codeCollection,
				memoCollection, categoryCollection, relationCollection.  
				Attributes: @ id, @ "standard-attributes group", @ status. 
			</xs:documentation>
		</xs:annotation>
		
		<!-- The sequence in which the core concepts should occur in qudex xml -->
		<xs:sequence>
			<xs:element name="resourceCollection" type="ResourceCollectionType" minOccurs="0"/>
			<xs:element name="segmentCollection" type="SegmentCollection" minOccurs="0"/>
			<xs:element name="codeCollection" type="CodeCollectionType" minOccurs="0"/>
			<xs:element name="memoCollection" type="MemoCollectionType" minOccurs="0"/>
			<xs:element name="categoryCollection" type="CategoryCollectionType" minOccurs="0"/>
			<xs:element name="relationCollection" type="RelationCollectionType" minOccurs="0"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attribute name="status" type="xs:string" use="optional"/>
	</xs:complexType>

	<!-- Resource Collection type definition-->
	<xs:complexType name="ResourceCollectionType">
		<xs:annotation>
			<xs:documentation>The resourceCollection section lists and locates all content available to the QuDEx file. 
				A source points to the original location of the resource while each author working on the QuDEx file 
				is assigned a surrogate document which points to the relevant source. 
				The child elements sources and memoSources contain direct references to the files under analysis; 
				the documents section contains their surrogates.   
				Child elements: sources, documents, memoSources. 
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="sources" type="SourcesType" minOccurs="0" maxOccurs="1"/>
			<xs:element name="memoSources" type="MemoSourcesType" minOccurs="0" maxOccurs="1"/>
			<xs:element name="documents" type="DocumentsType" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Sources type definition  --> 
	<xs:complexType name="SourcesType">
		<xs:annotation>
			<xs:documentation>Container class for holding the sources. 
				Child element: source. 
				Attributes: @id.  
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="source" type="SourceType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>
	
	<!-- Source type definition-->
	<xs:complexType name="SourceType">
		<xs:annotation>
			<xs:documentation>Each source represents a single resource available to the QuDEx file. 
				A source may be anything identifiable by a URI which is to be analysed using CAQDAS methodology. 
				Each time a new @creator uses a source, a document surrogate is created. 
				Other sections of the QuDEx instance reference the document rather than the source.
				Attributes: @id,  @ "resource-attributes" group, @ "standard-attributes" group 
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attributeGroup ref="resource-attributes"/>
	</xs:complexType>

	<!-- Memo Sources type definition-->
	<xs:complexType name="MemoSourcesType">
		<xs:annotation>
			<xs:documentation>Container for holding the external memo sources. 
				Child element: memoSource. 
				Attributes: @id. </xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="memoSource" type="MemoSourceType" minOccurs="0" maxOccurs="unbounded"
			/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Memo Source type definition-->
	<xs:complexType name="MemoSourceType">
		<xs:annotation>
			<xs:documentation>In addition to creating a pure text memo and embedding it in the QuDEx file (inline memo) 
				it is possible to reference an external memo using a memoSource. In QuDEx an external memo 
				(held outside the body of the QuDEx file) is managed in the same way as an external source.
				A memoSource may be anything identifiable by a URI. Each time a new @creator uses a memoSource,
				a document surrogate is created. Other sections of the QuDEx instance reference the document rather than the source.
				Attributes: @id,  @ "standard-attributes" group, @ "resource-attributes" group. 
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attributeGroup ref="resource-attributes"/>
	</xs:complexType>

	<!-- Documents type definition -->
	<xs:complexType name="DocumentsType">
		<xs:annotation>
			<xs:documentation> The different sources included in the QuDEx file may be used by a
				number of authors. This container element permits this as a resource is designated a
				new ‘document’ for each author instance which uses the resource.  
				Child element: document. 
				Attributes: @id. 
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="document" type="DocumentType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Document type definition  -->
	<xs:complexType name="DocumentType">
		<xs:annotation>
			<xs:documentation>A document is a surrogate version of a memo or memoSource specific to an individual author. 
				The first time each author (@creator) uses a source or memoSource in QuDEx a surrogate document is created. 
				This document is referenced by the various collection sections. The document concept permits the controlled 
				re-use and analysis of each source and memoSource within a single QuDEx instance. A document may refer to any 
				underlying resource (source or memoSource) that can be referenced by a URI including text, audio, video, still images and XML.
				Attributes: @id, @ "standard-attributes" group, @ documentType, @ resourceRef. 
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="resourceRef" type="xs:IDREF" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attribute name="documentType" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="source"/>
					<xs:enumeration value="memoSource"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
	</xs:complexType>

	<!-- Segment Collection type definition -->
	<xs:complexType name="SegmentCollection">
		<xs:annotation>
			<xs:documentation> The parent element for all segments.
				Child element: segment. 
				Attribute: @ id. </xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="segment" type="SegmentType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Segment type definition  -->
	<xs:complexType name="SegmentType">
		<xs:annotation>
			<xs:documentation>A subset of a document (text, audio, video or image) under analysis defined 
				in a manner appropriate to the format (text, audio, video, image or xml). Segments may overlap
				and multiple memos and codes may be assigned to a segment
				Child elements: text, audio, video, image and xml.
				Attributes: @ id, @ "standard-attributes" group.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:choice>
				<xs:element name="text" type="TextType" minOccurs="0"/>
				<xs:element name="audio" type="AudioType" minOccurs="0"/>
				<xs:element name="video" type="VideoType" minOccurs="0"/>
				<xs:element name="image" type="ImageType" minOccurs="0"/>
				<xs:element name="xml" type="XmlType" minOccurs="0"/>
			</xs:choice>
		</xs:sequence>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Text  type definition-->
	<xs:complexType name="TextType">
		<xs:annotation>
			<xs:documentation>Container for text document segment information.
				Child elements: lineParam, characterParam. 
				Attributes: @ id @ src.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:choice>
				<xs:element name="lineParam" type="LineParamType" minOccurs="1" maxOccurs="1"/>
				<xs:element name="characterParam" type="CharacterParamType" minOccurs="1"
					maxOccurs="1"/>
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
	</xs:complexType>

	<!-- Line Parameter type definition-->
	<xs:complexType name="LineParamType">
		<xs:annotation>
			<xs:documentation>Text document segment parameters based on lines and characters.
				Attributes: @id, @startLineOffset, @startOffset, @endLineOffset, @endOffset.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="startLine" type="xs:int" use="required"/>
		<xs:attribute name="startOffset" type="xs:int" use="required"/>
		<xs:attribute name="endLine" type="xs:int" use="required"/>
		<xs:attribute name="endOffset" type="xs:int" use="required"/>
	</xs:complexType>

	<!-- Character Parameter type definition-->
	<xs:complexType name="CharacterParamType">
		<xs:annotation>
			<xs:documentation>Text document segment parameters based on characters.
				Attributes: @id, @startCharOffset, @endCharOffset. </xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="startCharOffset" type="xs:int" use="required"/>
		<xs:attribute name="endCharOffset" type="xs:int" use="required"/>
	</xs:complexType>

	<!-- Audio type definition -->
	<xs:complexType name="AudioType">
		<xs:annotation>
			<xs:documentation>Container for audio segment information
				segments are defined. 
				Child elements: param. 
				Attributes are: @ id, @ src.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="param" type="AudioParamType" minOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
	</xs:complexType>

	<!-- Audio Parameter type definition -->
	<xs:complexType name="AudioParamType">
		<xs:annotation>
			<xs:documentation>audio segment parameters defined by start and end points for a clip.  
				Clip annotation may be taken from the enumerated list or user-defined. 
				Attributes : @id, @ clipBegin, @ clipEnd.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="clipType" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="byte"/>
					<xs:enumeration value="smil"/>
					<xs:enumeration value="midi"/>
					<xs:enumeration value="time"/>
					<xs:enumeration value="tcf"/>
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherClipType" type="xs:string" use="optional"/>
		<xs:attribute name="clipBegin" type="xs:string" use="required"/>
		<xs:attribute name="clipEnd" type="xs:string" use="required"/>
	</xs:complexType>

	<!-- Video type definition-->
	<xs:complexType name="VideoType">
		<xs:annotation>
			<xs:documentation>Container for video segment information. 
				Child elements: param. 
				Attributes: @ id, @ src.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="param" type="VideoParamType" minOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
	</xs:complexType>

	<!-- Video parameter type definition-->
	<xs:complexType name="VideoParamType">
		<xs:annotation>
			<xs:documentation> video segment parameters defined by start and end points for a clip. 
				Clip annotation may be taken from the enumerated list or user-defined. 
				Attributes: @ id, @ clipType, @ otherClipType,  @ clipBegin, @ clipEnd.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="clipType" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="byte"/>
					<!-- SMIL: a SMIL time value  -->
					<xs:enumeration value="smil"/>
					<!-- MIDI: a MIDI time code -->
					<xs:enumeration value="midi"/>
					<!--  SMPTE-25: SMPTE time code for 25 frame/second material -->
					<xs:enumeration value="smpte-25"/>
					<!--  SMPTE-24: SMPTE time code for 24 frame/second material -->
					<xs:enumeration value="smpte-24"/>
					<!--  SMPTE-DF30: SMPTE time code for 30 frame/second drop frame material -->
					<xs:enumeration value="smpte-df30"/>
					<!-- SMPTE-NDF30: SMPTE time code for 30 frame/second non-drop frame material  -->
					<xs:enumeration value="smpte-ndf30"/>
					<!--  SMPTE-DF29.97: SMPTE time code for 29.97 frame/second drop frame material -->
					<xs:enumeration value="smpte-df29.97"/>
					<!--  SMPTE-NDF29.97: SMPTE time code for 29.97 frame/second non-drop frame material -->
					<xs:enumeration value="smpte-ndf29.97"/>
					<!-- TIME: a simple time code of the form HH:MM:SS -->
					<xs:enumeration value="time"/>
					<!-- TCF: a Time code Character Format value -->
					<xs:enumeration value="tcf"/>
					<!-- Other type -->
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherClipType" type="xs:string" use="optional"/>
		<xs:attribute name="clipBegin" type="xs:string" use="required"/>
		<xs:attribute name="clipEnd" type="xs:string" use="required"/>
	</xs:complexType>

	<!-- Image type definition-->
	<xs:complexType name="ImageType">
		<xs:annotation>
			<xs:documentation> Container for image segment information.
				Child elements: area. 
				Attributes are : @ id, @ src
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="area" type="AreaType" minOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
	</xs:complexType>

	<!-- Image  type definition-->
	<xs:complexType name="AreaType">
		<xs:annotation>
			<xs:documentation>Image segment parameters are defined by the shape and coordinates of an area within the image.
				Attributes: @ id, @ shape (expected values are: rectangle, circle or polygon), @ coords.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="shape" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="rect"/>
					<xs:enumeration value="circ"/>
					<xs:enumeration value="poly"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="coords" type="xs:string" use="required"/>
	</xs:complexType>

	<!-- XML  type definition-->
	<xs:complexType name="XmlType">
		<xs:annotation>
			<xs:documentation>Container for XML segment information.
				Child element: range. 
				Attributes: @ id. </xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="node" type="NodeType" minOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Range  type definition-->
	<xs:complexType name="NodeType">
		<xs:annotation>
			<xs:documentation>XML segment parameters are defined by an Xpointer range
				Attributes: @ id, @ src, @ xPtrExp. </xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
		<xs:attribute name="xPtrExp" type="xs:string" use="optional"/>
	</xs:complexType>

	<!-- Code Collection type definition-->
	<xs:complexType name="CodeCollectionType">
		<xs:annotation>
			<xs:documentation>The parent element for all codes.
				Child element: code.
				Attribute: @ id. </xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="code" type="CodeType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Code type definition -->
	<xs:complexType name="CodeType">
		<xs:annotation>
			<xs:documentation>A short alphanumeric string, usually a single word; may be assigned to 
				a segment or document though assignment is not required. A code may optionally be 
				taken from a controlled vocabulary defined under @ authority.
				Attributes: @id, @label, @cdate, @mdate, and @creator. 
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
		<xs:attribute name="authority" type="xs:string" use="optional"/>
	</xs:complexType>

	<!-- Memo Collection type definition -->
	<xs:complexType name="MemoCollectionType">
		<xs:annotation>
			<xs:documentation>The parent element for all memos; these may be pure text and embedded
				in the QuDEx file (inline memo) or may refer to external files. 
				Child element: memo.
				Attribute: @ id. 
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="memo" type="MemoType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Memo type definition -->
	<xs:complexType name="MemoType">
		<xs:annotation>
			<xs:documentation> A text string internal to the document (inline memo) or an 
				externally held document (external memo) which may be assigned to a
				segment, code, document, category or to another memo. 
				Child elements: memoDocumentRef, memoText. 
				Attributes: @ id, @ "standard-attributes" group.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="memoDocumentRef" type="MemoDocumentRef" minOccurs="0"
				maxOccurs="unbounded"/>
			<xs:element name="memoText" type="MemoTextType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attributeGroup ref="standard-attributes"/>
	</xs:complexType>

	<!-- Memo Document Reference type definition -->
	<xs:complexType name="MemoDocumentRef">
		<xs:annotation>
			<xs:documentation>A reference to an external file to be used as a memo; 
				the reference must be to a memoSource via the id of a document. 
				Attributes: @ id, @ src.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="src" type="xs:IDREF" use="required"/>
	</xs:complexType>

	<!-- Memo Text  type definition-->
	<xs:complexType name="MemoTextType">
		<xs:annotation>
			<xs:documentation>An inline memo held as a single variable length alphanumeric string.
				Attributes: @ id.
			</xs:documentation>
		</xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="id" type="xs:ID" use="required"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<!-- Category Collection type definition -->
	<xs:complexType name="CategoryCollectionType">
		<xs:annotation>
			<xs:documentation> The parent element for all categories. 
				Child elements: category. 
				Attributes: @ id.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="category" type="CategoryType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Category type definition -->
	<xs:complexType name="CategoryType">
		<xs:annotation>
			<xs:documentation> An alphanumeric string (stored in @label) assigned to one or more documents. 
				Categories may be hierarchically nested. Documents contained within a category are referenced
				using @documentRefs. Nested categories are referenced using @categoryRefs.
				Attributes: @ id, @ documentRefs, @ categoryRefs, @ "standard group".
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="documentRefs" type="xs:IDREFS" use="optional"/>
		<xs:attribute name="categoryRefs" type="xs:IDREFS" use="optional"/>
		<xs:attributeGroup ref="standard-attributes"/>
	</xs:complexType>

	<!-- Relation Collection type definition  -->
	<xs:complexType name="RelationCollectionType">
		<xs:annotation>
			<xs:documentation>The parent element for all relationships between objects. 
				Child element: objectRelation.
				Attributes: @ id.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="objectRelation" type="ObjectRelationType" minOccurs="0"
				maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="id" type="xs:ID" use="required"/>
	</xs:complexType>

	<!-- Object Relation type definition   -->
	<xs:complexType name="ObjectRelationType">
		<xs:annotation>
			<xs:documentation>A relation is a link between two objects in a QuDEx file.  
				Each object is either the start or end point of a relation (source vs target).  
				Every relation may, optionally, have a name.
				For the purposes of a relation all of the following are considered to be ‘objects’: 
				a document (surrogate of a source or memoSource); 
				a segment within a document;
				an assigned value (code, memo, category, relation). 
				Attributes: @ id, @ objectType, @ relationName, @ otherRelationName, @ objectSource,
				@ objectTarget, @ "standard-attributes" group.
			</xs:documentation>
		</xs:annotation>
		<xs:attribute name="id" type="xs:ID" use="required"/>
		<xs:attribute name="objectType" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value=" "/>
					<xs:enumeration value="segmentSegment"/>
					<xs:enumeration value="segmentCode"/>
					<xs:enumeration value="segmentDocument"/>
					<xs:enumeration value="segmentCategory"/>
					<xs:enumeration value="segmentMemo"/>
					<xs:enumeration value="codeSegment"/>
					<xs:enumeration value="codeCode"/>
					<xs:enumeration value="codeDocument"/>
					<xs:enumeration value="codeCategory"/>
					<xs:enumeration value="codeMemo"/>
					<xs:enumeration value="documentSegment"/>
					<xs:enumeration value="documentCode"/>
					<xs:enumeration value="documentDocument"/>
					<xs:enumeration value="documentCategory"/>
					<xs:enumeration value="documentMemo"/>
					<xs:enumeration value="memoSegment"/>
					<xs:enumeration value="memoCode"/>
					<xs:enumeration value="memoDocument"/>
					<xs:enumeration value="memoCategory"/>
					<xs:enumeration value="memoMemo"/>
					<xs:enumeration value="categorySegment"/>
					<xs:enumeration value="categoryCode"/>
					<xs:enumeration value="categoryDocument"/>
					<xs:enumeration value="categoryCategory"/>
					<xs:enumeration value="categoryMemo"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="relationName" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="isA"/>
					<xs:enumeration value="isChildOf"/>
					<xs:enumeration value="isParentOf"/>
					<xs:enumeration value="isMemberOf"/>
					<xs:enumeration value="isDerivedFrom"/>
					<xs:enumeration value="isRevisionHistoryFor"/>
					<xs:enumeration value="isCriticalReviewOf"/>
					<xs:enumeration value="isOverviewOf"/>
					<xs:enumeration value="isVersionOf"/>
					<xs:enumeration value="isFormatOf"/>
					<xs:enumeration value="isReferencedBy"/>
					<xs:enumeration value="isBasedOn"/>
					<xs:enumeration value="isPartOf"/>
					<xs:enumeration value="isAssociateOf"/>
					<xs:enumeration value="isInstanceOf"/>
					<xs:enumeration value="isLinkedTo"/>
					<xs:enumeration value="isRelatedTo"/>
					<xs:enumeration value="isAssignedTo"/>
					<xs:enumeration value="isEqualTo"/>
					<xs:enumeration value="isNotEqualTo"/>
					<xs:enumeration value="hasFormat"/>
					<xs:enumeration value="hasVersion"/>
					<xs:enumeration value="hasPart"/>
					<xs:enumeration value="hasBibliographicInfoIn"/>
					<xs:enumeration value="references"/>
					<xs:enumeration value="requires"/>
					<xs:enumeration value="other"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="otherRelationName" type="xs:string" use="optional"/>
		<xs:attribute name="objectSource" type="xs:IDREF" use="optional"/>
		<xs:attribute name="objectTarget" type="xs:IDREF" use="optional"/>
		<xs:attributeGroup ref="standard-attributes"/>
	</xs:complexType>
</xs:schema>

