<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="unqualified" 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: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="classedSchemedElement">
		<xs:attributeGroup ref="classSchemeAttrGroup" />
		<xs:attributeGroup ref="optionalInferenceAttrGroup" />
	</xs:complexType>

	<xs:attributeGroup name="classSchemeAttrGroup">
		<xs:attribute name="classid" use="required" type="xs:string">
			<xs:annotation>
				<xs:documentation>Identifier of the value in classname with respect
					to the controlled
					vocabulary with id = schemeid.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="classname" use="required" type="xs:string">
			<xs:annotation>
				<xs:documentation>A value from the controlled vocabulary identified
					by
					schemeid.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="schemeid" use="required" type="xs:string">
			<xs:annotation>
				<xs:documentation>Identifier of the controlled vocabulary with name
					schemename. To see the classes included in the schema:
					$vocabulariesURL$/schemeid
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="schemename" use="required" type="xs:string">
			<xs:annotation>
				<xs:documentation>Name of the controlled vocabulary.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:attributeGroup>

	<xs:complexType mixed="true" name="optionalClassedSchemedElement">
		<xs:attributeGroup ref="optionalClassSchemeAttrGroup" />
		<xs:attributeGroup ref="optionalInferenceAttrGroup" />
	</xs:complexType>

	<xs:attributeGroup name="optionalClassSchemeAttrGroup">
		<xs:attribute name="classid" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Identifier of the value in classname with respect
					to the controlled
					vocabulary with id = schemeid.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="classname" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>A value from the controlled vocabulary identified
					by
					schemeid.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="schemeid" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Identifier of the controlled vocabulary with name
					schemename. To see the classes included in the schema:
					$vocabulariesURL$/schemeid
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="schemename" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Name of the controlled vocabulary.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:attributeGroup>

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

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

	<xs:complexType name="datainfoType">
		<xs:annotation>
			<xs:documentation>Information about the provenance of this record.
			</xs:documentation>
		</xs:annotation>
		<xs:choice maxOccurs="unbounded">
			<xs:element name="inferred" 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:element>
			<xs:element name="deletedbyinference" type="xs:boolean">
				<xs:annotation>
					<xs:documentation>True if this information has been deleted by the
						automatic inference
						algorithms run by OpenAIRE.
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="trust" type="xs:string">
				<xs:annotation>
					<xs:documentation>Value of trust of this information. Typically a
						value in the range
						[0,1]. Higher the value, more trustworthy is the information.
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="inferenceprovenance" type="xs:string">
				<xs:annotation>
					<xs:documentation>The algorithm that produced this property.
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="provenanceaction" type="classedSchemedElement">
				<xs:annotation>
					<xs:documentation>Describes the process/action that produced the
						information.</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:choice>
	</xs:complexType>

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

	<xs:complexType name="relType">
		<xs:annotation>
			<xs:documentation>A relationship to another entity</xs:documentation>
		</xs:annotation>
		<xs:choice maxOccurs="unbounded">
			<xs:element name="to" type="relToType" />
			<xs:element name="ranking" type="xs:integer" minOccurs="0" />
			<xs:element name="fullname" type="xs:string" minOccurs="0" />
			<xs:element name="title" type="optionalClassedSchemedElement"
				minOccurs="0">
				<xs:annotation>
					<xs:documentation>
						Title of the related research result.
						<p>Different types of titles are allowed: see
							$vocabulariesURL$/dnet:dataCite_title
						</p>
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="dateofacceptance" type="xs:string"
				minOccurs="0" />
			<xs:element name="publisher" type="xs:string" minOccurs="0" />
			<xs:element name="resulttype" type="classedSchemedElement"
				minOccurs="0">
				<xs:annotation>
					<xs:documentation>
						Tells if the related record is about a publication or a dataset.
						<p>For allowed values check:
							$vocabulariesURL$/dnet:result_typologies
						</p>
					</xs:documentation>
				</xs:annotation>
			</xs:element>

			<!-- elements for organisations, some are also valid for datsources and 
				projects -->
			<xs:element name="officialname" type="xs:string"
				minOccurs="0" />
			<xs:element name="participantnumber" type="xs:string"
				minOccurs="0" />
			<xs:element name="websiteurl" type="xs:string" minOccurs="0" />
			<xs:element name="code" type="xs:string" minOccurs="0" />
			<xs:element name="acronym" type="xs:string" minOccurs="0" />
			<xs:element name="contracttype" type="optionalClassedSchemedElement"
				minOccurs="0">
				<xs:annotation>
					<xs:documentation>
						Type of the contract. Available if the related entity is a project.
						<p>
							Allowed values depend on the actual funder of the related project. Currently supported
							funders and corresponding contract types are:
							<table>
								<tr>
									<th>Funder</th>
									<th>Funder id</th>
									<th>Contract types</th>
								</tr>
								<tr>
									<td>FP7</td>
									<td>corda_______::FP7</td>
									<td>$vocabulariesURL$/ec:FP7contractTypes</td>
								</tr>
								<tr>
									<td>Wellcome Trust</td>
									<td>wt::WT</td>
									<td>$vocabulariesURL$/wt:contractTypes</td>
								</tr>
							</table>
						</p>
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="funding" type="fundingFlatType"
				minOccurs="0" />
			<!-- elements for datasources -->
			<xs:element name="legalname" type="xs:string" minOccurs="0" />
			<xs:element name="datasourcetype" type="optionalClassedSchemedElement"
				minOccurs="0">
				<xs:annotation>
					<xs:documentation>
						Type of the related data source.
						<p>For allowed values check codes in:
							$vocabulariesURL$/dnet:datasource_typologies
						</p>
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="datasourcetypeui" type="optionalClassedSchemedElement"
				minOccurs="0" ><xs:annotation>
					<xs:documentation>
						Type of this data source to be displayed in the OpenAire
						portal.
						<p>For allowed values check terms in:
							$vocabulariesURL$/dnet:datasource_typologies
						</p>
					</xs:documentation>
				</xs:annotation>
				</xs:element>
			<xs:element name="legalshortname" type="xs:string"
				minOccurs="0" />
			<xs:element name="country" type="optionalClassedSchemedElement"
				minOccurs="0">
				<xs:annotation>
					<xs:documentation>
						Countries in ISO 3166-1 alpha-2.
						<p>For allowed values check:
							$vocabulariesURL$/dnet:countries
						</p>
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<!-- elements for projects -->
			<xs:element name="fax" type="xs:string" minOccurs="0" />
			<xs:element name="email" type="xs:string" minOccurs="0" />
			<xs:element name="phone" type="xs:string" minOccurs="0" />
		</xs:choice>
		<xs:attributeGroup ref="optionalInferenceAttrGroup" />
		<xs:attribute name="provenanceaction" type="xs:string" />
	</xs:complexType>

	<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="scheme" 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="funding_level_0" type="xs:string"
				minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="funding_level_1" type="xs:string"
				minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="funding_level_2" type="xs:string"
				minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="externalreferenceType">
		<xs:sequence>
			<xs:element name="sitename" type="xs:string" />
			<xs:element name="label" type="xs:string" />
			<xs:element name="qualifier" type="optionalClassedSchemedElement" />
			<xs:element name="refidentifier" type="xs:string" />
		</xs:sequence>
		<xs:attributeGroup ref="optionalInferenceAttrGroup" />
	</xs:complexType>

	<xs:complexType name="extraInfoType">
		<xs:annotation>
			<xs:documentation>Fields of this type can contain any well-formed
				XML, regardless of the
				actual structure.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required">
			<xs:annotation>
				<xs:documentation>Human readable label that explains the type of
					information we can find
					inside this element. It corresponds to the value in the "typology"
					attribute.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="typology" type="xs:string" use="required">
			<xs:annotation>
				<xs:documentation>Type of the information we can find inside this
					element. The attribute
					"name" provides a human-readable label of this very same information.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="provenance" type="xs:string" />
		<xs:attribute name="trust" type="xs:string">
			<xs:annotation>
				<xs:documentation>Value of trust of this information. Typically a
					value in the range [0,1].
					Higher the value, more trustworthy is the information.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

</xs:schema>
