<?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: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="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: http://api.openaire.eu/vocabularies/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: http://api.openaire.eu/vocabularies/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: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="optionalClassedSchemedElement" />
				<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="datasourcetypeui" type="classedSchemedElement">
					<xs:annotation>
						<xs:documentation> Type of this data source to be displayed in the OpenAire
							portal. <p>For allowed values check terms in:
								http://api.openaire.eu/vocabularies/dnet:datasource_typologies </p>
						</xs:documentation>
					</xs:annotation>
				</xs:element>
				<xs:element name="datasourcetype" type="classedSchemedElement">
					<xs:annotation>
						<xs:documentation> Type of the related data source. <p>For allowed values
								check codes in: http://api.openaire.eu/vocabularies/dnet:datasource_typologies </p>
						</xs:documentation>
					</xs:annotation>
				</xs:element>
			</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="classedSchemedElement">
					<xs:annotation>
						<xs:documentation> Tells if the related record is about a publication or a
							dataset. <p>For allowed values check:
								http://api.openaire.eu/vocabularies/dnet:result_typologies </p>
						</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="optionalClassedSchemedElement">
					<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>http://api.openaire.eu/vocabularies/ec:FP7contractTypes</td>
									</tr>
									<tr>
										<td>Wellcome Trust</td>
										<td>wt::WT</td>
										<td>http://api.openaire.eu/vocabularies/wt:contractTypes</td>
									</tr>
								</table>
							</p>
						</xs:documentation>
					</xs:annotation>
				</xs:element>
				<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="optionalClassedSchemedElement">
					<xs:annotation>
						<xs:documentation> Countries in ISO 3166-1 alpha-2. <p>For allowed values
								check: http://api.openaire.eu/vocabularies/dnet:countries </p>
						</xs:documentation>
					</xs:annotation>
				</xs:element>
			</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="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="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="optionalClassedSchemedElement" minOccurs="0" maxOccurs="1"/>
			<xs:element name="refidentifier" type="xs:string" minOccurs="0" maxOccurs="1"/>
		</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>
