<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.alfresco.org/model/dictionary/1.0" xmlns:dd="http://www.alfresco.org/model/dictionary/1.0" elementFormDefault="qualified" version="0.1">

    <xs:annotation>
    	<xs:documentation>Alfresco Data Dictionary Schema - DRAFT</xs:documentation>
    </xs:annotation>
    
    <xs:element name="model">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="description" type="xs:string" maxOccurs="1" minOccurs="0"/>
				<xs:element name="author" type="xs:string" maxOccurs="1" minOccurs="0"/>
				<xs:element name="published" type="xs:date" maxOccurs="1" minOccurs="0"/>
				<xs:element name="version" type="xs:string" maxOccurs="1" minOccurs="0"/>
				<xs:element name="imports" maxOccurs="1" minOccurs="0">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="import" maxOccurs="unbounded" minOccurs="1">
								<xs:complexType>
									<xs:attributeGroup ref="dd:namespaceDefinition"/>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="namespaces">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="namespace" maxOccurs="unbounded" minOccurs="1">
								<xs:complexType>
									<xs:attributeGroup ref="dd:namespaceDefinition"/>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="property-types" maxOccurs="1" minOccurs="0">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="property-type" maxOccurs="unbounded" minOccurs="1">
								<xs:complexType>
									<xs:sequence>
										<xs:group ref="dd:TextualDescription"/>
										<xs:element name="analyser-class" maxOccurs="1" minOccurs="0"/>
										<xs:element name="java-class" maxOccurs="1" minOccurs="0"/>
									</xs:sequence>
									<xs:attributeGroup ref="dd:name"/>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="types" maxOccurs="1" minOccurs="0">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="type" type="dd:type" maxOccurs="unbounded" minOccurs="1"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="aspects" maxOccurs="1" minOccurs="0">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="aspect" type="dd:aspect" maxOccurs="unbounded" minOccurs="1"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
			<xs:attributeGroup ref="dd:name"/>
		</xs:complexType>
	</xs:element>

	<xs:complexType name="class">
		<xs:sequence>
			<xs:group ref="dd:TextualDescription"></xs:group>
			<xs:element name="parent" type="xs:string" maxOccurs="1" minOccurs="0"/>
			<xs:element name="properties" maxOccurs="1" minOccurs="0">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="property" type="dd:property" maxOccurs="unbounded" minOccurs="1"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="associations" maxOccurs="1" minOccurs="0">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="association" type="dd:association" maxOccurs="unbounded" minOccurs="0"/>
						<xs:element name="child-association" type="dd:childAssociation" maxOccurs="unbounded" minOccurs="0"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="overrides" maxOccurs="1" minOccurs="0">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="propertyOverrides" maxOccurs="1" minOccurs="0">
							<xs:complexType>
								<xs:sequence>
									<xs:element name="property" type="dd:propertyOverride" maxOccurs="unbounded" minOccurs="1"/>
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attributeGroup ref="dd:name" />
	</xs:complexType>

	<xs:complexType name="property">
		<xs:sequence>
			<xs:group ref="dd:TextualDescription"/>
			<xs:element name="type" type="xs:string"/>
			<xs:element name="protected" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
			<xs:element name="mandatory" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
			<xs:element name="multiple" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
			<xs:element name="default" type="xs:anyType" maxOccurs="1" minOccurs="0"/>
			<xs:element name="index" maxOccurs="1" minOccurs="0">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="atomic" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
						<xs:element name="stored" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
						<xs:element name="tokenised" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
					</xs:sequence>
					<xs:attribute name="enabled" type="xs:boolean" use="required"/>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attributeGroup ref="dd:name"/>
	</xs:complexType>

	<xs:complexType name="type">
		<xs:complexContent>
			<xs:extension base="dd:class">
				<xs:sequence>
					<xs:element name="mandatory-aspects" maxOccurs="1" minOccurs="0">
						<xs:complexType>
							<xs:sequence>
								<xs:element name="aspect" type="xs:string" maxOccurs="unbounded" minOccurs="1"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:complexType name="aspect">
		<xs:complexContent>
			<xs:extension base="dd:class"></xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:complexType name="association">
		<xs:sequence>
			<xs:group ref="dd:TextualDescription"></xs:group>
			<xs:element name="source" maxOccurs="1" minOccurs="0">
				<xs:complexType>
					<xs:sequence>
						<xs:group ref="dd:role"></xs:group>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="target">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="class" type="xs:string"></xs:element>
						<xs:group ref="dd:role"></xs:group>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attributeGroup ref="dd:name"/>
	</xs:complexType>

	<xs:complexType name="childAssociation">
		<xs:complexContent>
			<xs:extension base="dd:association">
				<xs:sequence>
					<xs:element name="child-name" type="xs:string" maxOccurs="1" minOccurs="0"/>
					<xs:element name="duplicate" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:group name="role">
		<xs:sequence>
			<xs:element name="role" type="xs:string" maxOccurs="1" minOccurs="0"/>
			<xs:element name="mandatory" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
			<xs:element name="many" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
		</xs:sequence>
	</xs:group>

	<xs:complexType name="propertyOverride">
		<xs:sequence>
			<xs:element name="mandatory" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
			<xs:element name="default" type="xs:boolean" maxOccurs="1" minOccurs="0"/>
		</xs:sequence>
		<xs:attributeGroup ref="dd:name"/>
	</xs:complexType>

	<xs:attributeGroup name="namespaceDefinition">
		<xs:attribute name="uri" type="xs:string" use="required" />
		<xs:attribute name="prefix" type="xs:string" use="required" />
	</xs:attributeGroup>

	<xs:attributeGroup name="name">
		<xs:attribute name="name" type="xs:string" use="required" />
	</xs:attributeGroup>

	<xs:group name="TextualDescription">
		<xs:sequence>
			<xs:element name="title" type="xs:string" maxOccurs="1" minOccurs="0"/>
			<xs:element name="description" type="xs:string" maxOccurs="1" minOccurs="0"/>
		</xs:sequence>
	</xs:group>

</xs:schema>
