<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
	xmlns="http://namespace.openaire.eu/oaf" targetNamespace="http://namespace.openaire.eu/oaf">

	<xs:annotation>
		<xs:documentation>This schema defines common types that can be re-used.</xs:documentation>
	</xs:annotation>

	<xs:simpleType name="emptyType">
		<xs:restriction base="xs:string">
			<xs:length value="0"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="boolOrEmptyType">
		<xs:union memberTypes="emptyType xs:boolean"/>
	</xs:simpleType>

	<xs:simpleType name="stringOrEmptyType">
		<xs:union memberTypes="emptyType xs:string"/>
	</xs:simpleType>

	<xs:complexType mixed="true" name="inferenceExtendedStringType">
		<xs:annotation>
			<xs:documentation>XML elements of this type are simple strings, but in cases where their
				values have been inferred by Openaire inference algorithms, the elements features
				some attributes describing the inference algorithm. This way it is easy to
				understand if a value comes from the originally imported data or if it has been
				added later for enrichment. </xs:documentation>
		</xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType mixed="true" name="inferenceExtendedBooleanType">
		<xs:annotation>
			<xs:documentation>XML elements of this type are simple booleans, but in cases where
				their values have been inferred by Openaire inference algorithms, the elements
				features some attributes describing the inference algorithm. This way it is easy to
				understand if a value comes from the originally imported data or if it has been
				added later for enrichment. </xs:documentation>
		</xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:boolean">
				<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:attributeGroup name="optionalInferenceAttrGroup">
		<xs:attribute name="inferred" use="optional" type="xs:boolean">
			<xs:annotation>
				<xs:documentation>True if this information has been inferred by the automatic
					inference algorithms run by OpenAIRE. </xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="inferenceprovenance" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Which algorithm inferred the current property. </xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="trust" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Value of trust of this information in the range [0,1]. More the
					value, more trustworthy is the information. </xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:attributeGroup>

	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->

	<xs:complexType mixed="true" name="controlledElementType">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="code" use="required" type="xs:string"/>
				<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<!--
	<xs:complexType mixed="true" name="optionalControlledElementType">
		<xs:attribute name="code" use="optional" type="xs:string"/>
		<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
	</xs:complexType>
	-->

	<xs:complexType name="namedIdElementType">
		<xs:attribute name="id" use="required"/>
		<xs:attribute name="name" use="required"/>
		<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
	</xs:complexType>

	<xs:complexType name="labeledIdElementType">
		<xs:attribute name="id" use="required"/>
		<xs:attribute name="label" use="required"/>
		<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
	</xs:complexType>

	<xs:complexType name="typedElementType">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="type" use="required"/>
				<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
			</xs:extension>
		</xs:simpleContent>
		
	</xs:complexType>


	<xs:complexType name="relsType">
		<xs:annotation>
			<xs:documentation>Relationships to other entities.</xs:documentation>
		</xs:annotation>
		<xs:choice maxOccurs="unbounded" minOccurs="0">
			<xs:element name="rel" type="relType" minOccurs="0"/>
		</xs:choice>
	</xs:complexType>

	<xs:complexType name="relType">
		<xs:sequence>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="to" type="relToType"/>
				<xs:element name="title" type="xs:string"/>
				<xs:element name="websiteurl"/>
				<xs:choice>
					<xs:group ref="relPersonGroup"/>
					<xs:group ref="relDataSourceGroup"/>
					<xs:group ref="relResultGroup"/>
					<xs:group ref="relProjectGroup"/>
					<xs:group ref="relOrganizationGroup"/>
					<xs:group ref="fundingGroup"/>
				</xs:choice>
			</xs:choice>
		</xs:sequence>
		<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
		<xs:attribute name="provenanceaction" type="xs:string"/>
	</xs:complexType>


	<xs:group name="relPersonGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="ranking" type="xs:integer"/>
				<xs:element name="fullname" type="xs:string"/>
				<xs:element name="fax" type="xs:string"/>
				<xs:element name="email" type="xs:string"/>
				<xs:element name="phone" type="xs:string"/>
			</xs:choice>
		</xs:sequence>
	</xs:group>

	<xs:group name="relDataSourceGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="officialname" type="xs:string"/>
				<xs:element name="datasourcetype" type="controlledElementType"/>
			</xs:choice>
		</xs:sequence>
	</xs:group>

	<xs:group name="relResultGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="dateofacceptance" type="xs:string"/>
				<xs:element name="publisher" type="xs:string"/>
				<xs:element name="resulttype" type="xs:string">
					<xs:annotation>
						<xs:documentation> Tells if the related record is about a publication or a
							dataset. </xs:documentation>
					</xs:annotation>
				</xs:element>
				<!-- the following fields are available only for similarity relations -->
				<xs:element name="similarity" type="xs:double">
					<xs:annotation>
						<xs:documentation>The similarity degree expressed in the range (0,1]. This
							field is avaiable only when the to/@class is one of
							{hasAmongTopNSimilarDocuments,
							isAmongTopNSimilarDocuments}</xs:documentation>
					</xs:annotation>
				</xs:element>
				<xs:element name="type">
					<xs:annotation>
						<xs:documentation>The similarity degree expressed in the range (0,1]. This
							field is avaiable only when the to/@class is one of
							{hasAmongTopNSimilarDocuments,
							isAmongTopNSimilarDocuments}</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:enumeration value="STANDARD"/>
							<xs:enumeration value="WEBUSAGE"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
			</xs:choice>
		</xs:sequence>
	</xs:group>

	<xs:group name="relProjectGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="code" type="xs:string"/>
				<xs:element name="acronym" type="xs:string"/>
			</xs:choice>
		</xs:sequence>
	</xs:group>

	<xs:group name="fundingGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="contracttype" type="controlledElementType"/>
				<xs:element name="funding" type="fundingFlatType"/>
			</xs:choice>
		</xs:sequence>
	</xs:group>

	<xs:group name="relOrganizationGroup">
		<xs:sequence>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="legalname" type="xs:string"/>
				<xs:element name="legalshortname" type="xs:string"/>
				<xs:element name="country" type="controlledElementType"/>
			</xs:choice>
		</xs:sequence>
	</xs:group>


	<xs:complexType name="relToType">
		<xs:annotation>
			<xs:documentation>Information about the related entity. <p>The semantics of the
					relationships is expressed by the attributes class and scheme. </p>
				<!--  <p>See the following ontology for the available relationships: $ontologyURL$</p>-->
				<p>Allowed relationships are: <table>
						<tr><th>Entity types</th><th>Name of relationships</th><th>Inverse
								of</th><th>Simmetric</th></tr>
						<tr><td>Project --
								Person</td><td>hasContact</td><td>isContact</td><td>no</td></tr>
						<tr><td>Project --
								Result</td><td>produces</td><td>isProducedBy</td><td>no</td></tr>
						<tr><td>Project --
								Organization</td><td>hasParticipant</td><td>isParticipant</td><td>no</td></tr>
						<tr><td>Person --
								Project</td><td>isContact</td><td>hasContact</td><td>no</td></tr>
						<tr><td>Person --
								Result</td><td>isAuthorOf</td><td>hasAuthor</td><td>no</td></tr>
						<tr><td>Person --
							Person</td><td>isCoauthorOf</td><td>--</td><td>yes</td></tr>
						<tr><td>Result --
								Person</td><td>hasAuthor</td><td>isAuthorOf</td><td>no</td></tr>
						<tr><td>Result --
								Project</td><td>isProducedBy</td><td>produces</td><td>no</td></tr>
						<tr><td>Result --
							Result</td><td>isRelatedTo</td><td>--</td><td>yes</td></tr>
						<tr><td>Result --
								Result</td><td>hasAmongTopNSimilarDocuments</td><td>isAmongTopNSimilarDocuments</td><td>no</td></tr>
						<tr><td>Result --
								Result</td><td>isAmongTopNSimilarDocuments</td><td>hasAmongTopNSimilarDocuments</td><td>no</td></tr>
						<tr><td>Organization --
								Datasource</td><td>isProvidedBy</td><td>provides</td><td>no</td></tr>
						<tr><td>Organization --
								Project</td><td>isParticpant</td><td>hasParticipant</td><td>no</td></tr>
						<tr><td>Datasource --
								Organization</td><td>provides</td><td>isProvidedBy</td><td>no</td></tr>
					</table></p>
			</xs:documentation>
		</xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="class" use="required" type="xs:string"/>
				<xs:attribute name="type" use="required" type="xs:string">
					<xs:annotation>
						<xs:documentation>The type of the related entity. <p>Allowed values are:
								project, organization, datasource, result, person.</p>
						</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name="fundingFlatType">
		<xs:sequence>
			<xs:element name="funder" type="funderFlatType" minOccurs="1" maxOccurs="1"/>
			<xs:element name="funding_level_0" type="namedFundingLevel" minOccurs="0"
				maxOccurs="unbounded"/>
			<xs:element name="funding_level_1" type="namedFundingLevel" minOccurs="0"
				maxOccurs="unbounded"/>
			<xs:element name="funding_level_2" type="namedFundingLevel" minOccurs="0"
				maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="funderFlatType">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="id" use="required" type="xs:string"/>
				<xs:attribute name="shortname" use="required" type="xs:string"/>
				<xs:attribute name="name" use="required" type="xs:string"/>
				<xs:attribute name="jurisdiction" use="optional" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name="namedFundingLevel">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="name" use="required" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name="externalreferenceType">
		<xs:sequence>
			<xs:element name="sitename" type="xs:string" minOccurs="0" maxOccurs="1"/>
			<!--<xs:element name="label" type="xs:string" minOccurs="0" maxOccurs="1"/>-->
			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1"/>
			<xs:element name="qualifier" type="controlledElementType" minOccurs="0" maxOccurs="1"/>
			<xs:element name="refidentifier" type="xs:string" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:attributeGroup ref="optionalInferenceAttrGroup"/>
	</xs:complexType>


</xs:schema>
