additional XSLT transformation scripts, enhance methods #97

Closed
andreas.czerniak wants to merge 49 commits from hadoop_aggregator into hadoop_aggregator
16 changed files with 4085 additions and 4 deletions

4
.gitignore vendored
View File

@ -7,6 +7,8 @@
*.iws
*~
.vscode
.metals
.bloop
.classpath
/*/.classpath
/*/*/.classpath
@ -24,4 +26,4 @@
spark-warehouse
/**/job-override.properties
/**/*.log
/**/.factorypath

View File

@ -1,4 +1,3 @@
package eu.dnetlib.dhp.common.vocabulary;
import java.io.Serializable;
@ -122,7 +121,31 @@ public class VocabularyGroup implements Serializable {
return vocs.get(vocId.toLowerCase()).getSynonymAsQualifier(syn);
}
/**
* getSynonymAsQualifierCaseSensitive
*
* refelects the situation to check caseSensitive vocabulary
*/
public Qualifier getSynonymAsQualifierCaseSensitiv(final String vocId, final String syn) {
if (StringUtils.isBlank(vocId)) {
return OafMapperUtils.unknown("", "");
}
return vocs.get(vocId).getSynonymAsQualifier(syn);
}
/**
* termExists
*
* two methods: without and with caseSensitive check
*/
public boolean termExists(final String vocId, final String id) {
return termExists(vocId, id, Boolean.FALSE);
}
public boolean termExists(final String vocId, final String id, final Boolean caseSensitive) {
if (Boolean.TRUE.equals(caseSensitive)) {
return vocabularyExists(vocId) && vocs.get(vocId).termExists(id);
}
return vocabularyExists(vocId) && vocs.get(vocId.toLowerCase()).termExists(id);
}

View File

@ -9,6 +9,26 @@ import org.apache.commons.io.IOUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* VocabularyHelper
*
* used names of vocabulary in dnet45 transformation
* detailed information at https://issue.openaire.research-infrastructures.eu/projects/openaire/wiki/Transformation_Rule_Language :
* "AccessRights":
* {"name":"dnet:access_modes", "caseSensitive":"false"},
* "Languages":
* {"name":"dnet:languages", "caseSensitive":"false", "delimiter":"/"},
* "TextTypologies":
* {"name":"dnet:publication_resource", "caseSensitive":"false"},
* "SuperTypes":
* {"name":"dnet:result_typologies", "caseSensitive":"false"},
* "ReviewLevels":
* {"name":"dnet:review_levels", "caseSensitive":"false"},
* "Countries":
* {"name":"dnet:countries", "caseSensitive":"false"}
*
*/
public class VocabularyHelper implements Serializable {
private static final String OPENAIRE_URL = "http://api.openaire.eu/vocabularies/%s.json";

View File

@ -0,0 +1,119 @@
package eu.dnetlib.dhp.transformation.xslt;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import net.sf.saxon.s9api.*;
import scala.Serializable;
//import eu.dnetlib.data.collective.transformation.engine.functions.ProcessingException;
// import org.apache.kafka.clients.producer.KafkaProducer;
// import org.apache.kafka.clients.producer.Producer;
// import org.apache.kafka.clients.producer.ProducerConfig;
// import org.apache.kafka.common.serialization.LongSerializer;
// import org.apache.kafka.common.serialization.StringSerializer;
public class TransformationFunctionProxy implements ExtensionFunction, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private final VocabularyGroup vocabularies;
private final Properties props;
public TransformationFunctionProxy(final VocabularyGroup vocabularies) {
this.vocabularies = vocabularies;
/* initialize producer for Kafka events */
props = new Properties();
props.put("bootstrap.servers", "events.dnet.openaire.eu:9092");
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
}
@Override
public QName getName() {
return new QName("http://eu/dnetlib/transform/functionProxy", "TransformationFunction");
}
@Override
public SequenceType getResultType() {
return SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ONE_OR_MORE);
}
@Override
public SequenceType[] getArgumentTypes() {
return new SequenceType[] {
SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ZERO_OR_MORE),
SequenceType.makeSequenceType(ItemType.STRING, OccurrenceIndicator.ONE)
};
}
@Override
public XdmValue call(XdmValue[] xdmValues) throws SaxonApiException {
XdmValue r = xdmValues[0];
if (r.size() == 0) {
return new XdmAtomicValue("");
}
final String currentValue = xdmValues[0].itemAt(0).getStringValue();
final String vocabularyName = xdmValues[1].itemAt(0).getStringValue();
Qualifier cleanedValue = vocabularies.getSynonymAsQualifier(vocabularyName, currentValue);
return new XdmAtomicValue(
cleanedValue != null ? cleanedValue.getClassid() : currentValue);
}
/**
* normalize values given as an input value by using a vocabulary
* @param aInput - the value as a String
* @param aVocabularyName - the name of the vocabulary, which must be known for the vocabulary registry
* @return
*/
public synchronized String convertString(String aInput, String aVocabularyName){
List<String> values = new LinkedList<>();
// Producer<String, String> producer = new KafkaProducer<>(props);
values.add(aInput);
try {
String conversion;
// log.debug("conversion input: " + aInput);
// producer.send(new ProducerRecord<String, String>("transformation-vocab", "conversion innput", aInput));
// String conversionResult = executeSingleValue(aVocabularyName, values);
String conversionResult = "";
// log.debug("conversion result: " + conversionResult);
// producer.send(new ProducerRecord<String, String>("transformation-vocab", "conversion result", conversionResult));
return conversionResult;
// } catch (ProcessingException e) {
} catch (Exception e) {
// log.fatal("convert failed for args 'input': " + aInput + " , 'vocabularyName': " + aVocabularyName, e);
// producer.send(new ProducerRecord<String, String>("transformation-vocab", "convert failed", aVocabularyName));
throw new IllegalStateException(e);
}
/* catch (KafkaException e) {
// For all other exceptions, just abort the transaction and try again.
producer.abortTransaction();
}
*/
// producer.close();
}
}

View File

@ -51,13 +51,12 @@ public class TransformationJobTest extends AbstractVocabularyTest {
}
@Test
@DisplayName("Test Transform Single XML using XSLTTransformator")
@DisplayName("Test Transform Single XML using zenodo_tr XSLTTransformator")
public void testTransformSaxonHE() throws Exception {
// We Set the input Record getting the XML from the classpath
final MetadataRecord mr = new MetadataRecord();
mr.setBody(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/transform/input_zenodo.xml")));
// We Load the XSLT transformation Rule from the classpath
XSLTTransformationFunction tr = loadTransformationRule("/eu/dnetlib/dhp/transform/zenodo_tr.xslt");
@ -68,6 +67,121 @@ public class TransformationJobTest extends AbstractVocabularyTest {
// TODO Create significant Assert
}
@Test
@DisplayName("Test Transform Inst.&Them.v4 record XML with zenodo_tr")
public void testTransformITGv4Zenodo() throws Exception {
// We Set the input Record getting the XML from the classpath
final MetadataRecord mr = new MetadataRecord();
mr.setBody(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/transform/input_itgv4.xml")));
// We Load the XSLT transformation Rule from the classpath
XSLTTransformationFunction tr = loadTransformationRule("/eu/dnetlib/dhp/transform/zenodo_tr.xslt");
MetadataRecord result = tr.call(mr);
// Print the record
System.out.println(result.getBody());
// TODO Create significant Assert
}
@Test
@DisplayName("Test Transform Inst.&Them.v4 record XML with xslt_cleaning_oaiOpenaire_datacite_ExchangeLandingpagePid")
public void testTransformITGv4() throws Exception {
// We Set the input Record getting the XML from the classpath
final MetadataRecord mr = new MetadataRecord();
mr.setBody(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/transform/input_itgv4.xml")));
// We Load the XSLT transformation Rule from the classpath
XSLTTransformationFunction tr = loadTransformationRule("/eu/dnetlib/dhp/transform/scripts/xslt_cleaning_oaiOpenaire_datacite_ExchangeLandingpagePid.xsl");
MetadataRecord result = tr.call(mr);
// Print the record
System.out.println(result.getBody());
// TODO Create significant Assert
}
@Test
@DisplayName("Test Transform record XML with xslt_cleaning_datarepo_datacite")
public void testTransformMostlyUsedScript() throws Exception {
// We Set the input Record getting the XML from the classpath
final MetadataRecord mr = new MetadataRecord();
mr.setBody(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/transform/input_itgv4.xml")));
// We Load the XSLT transformation Rule from the classpath
XSLTTransformationFunction tr = loadTransformationRule("/eu/dnetlib/dhp/transform/scripts/xslt_cleaning_datarepo_datacite.xsl");
MetadataRecord result = tr.call(mr);
// Print the record
System.out.println(result.getBody());
// TODO Create significant Assert
}
@Test
@DisplayName("Test TransformSparkJobNode.main with oaiOpenaire_datacite (v4)")
public void transformTestITGv4OAIdatacite(@TempDir Path testDir) throws Exception {
SparkConf conf = new SparkConf();
conf.setAppName(TransformationJobTest.class.getSimpleName());
conf.setMaster("local");
try (SparkSession spark = SparkSession.builder().config(conf).getOrCreate()) {
final String mdstore_input = this
.getClass()
.getResource("/eu/dnetlib/dhp/transform/mdstorenative")
.getFile();
final String mdstore_output = testDir.toString() + "/version";
mockupTrasformationRule("simpleTRule", "/eu/dnetlib/dhp/transform/scripts/xslt_cleaning_oaiOpenaire_datacite_ExchangeLandingpagePid.xsl");
final Map<String, String> parameters = Stream.of(new String[][] {
{
"dateOfTransformation", "1234"
},
{
"varOfficialName", "Publications at Bielefeld University"
},
{
"varOfficialId", "opendoar____::2294"
},
{
"transformationPlugin", "XSLT_TRANSFORM"
},
{
"transformationRuleId", "simpleTRule"
},
}).collect(Collectors.toMap(data -> data[0], data -> data[1]));
TransformSparkJobNode.transformRecords(parameters, isLookUpService, spark, mdstore_input, mdstore_output);
// TODO introduce useful assertions
final Encoder<MetadataRecord> encoder = Encoders.bean(MetadataRecord.class);
final Dataset<MetadataRecord> mOutput = spark
.read()
.format("parquet")
.load(mdstore_output + MDSTORE_DATA_PATH)
.as(encoder);
final Long total = mOutput.count();
final long recordTs = mOutput
.filter((FilterFunction<MetadataRecord>) p -> p.getDateOfTransformation() == 1234)
.count();
final long recordNotEmpty = mOutput
.filter((FilterFunction<MetadataRecord>) p -> !StringUtils.isBlank(p.getBody()))
.count();
assertEquals(total, recordTs);
assertEquals(total, recordNotEmpty);
}
}
@Test
@DisplayName("Test TransformSparkJobNode.main")
public void transformTest(@TempDir Path testDir) throws Exception {

View File

@ -0,0 +1,44 @@
package eu.dnetlib.dhp.transformation.xslt;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.SequenceType;
public class TransformationFunctionProxyTest {
private VocabularyGroup vocabularies;
private TransformationFunctionProxy transformationFunctionProxy;
public void setup() {
this.transformationFunctionProxy = new TransformationFunctionProxy(vocabularies);
}
@Test
public void shouldGetName() {
QName actualValue = transformationFunctionProxy.getName();
String nameSpaceUri = actualValue.getNamespaceURI();
String prefixName = actualValue.getPrefix();
assertEquals("http://eu/dnetlib/transform/functionProxy", nameSpaceUri);
assertEquals("TransformationFunction", prefixName);
}
@Test
public void shouldGetResultType() {
SequenceType actualValue = transformationFunctionProxy.getResultType();
// TODO: assert scenario
}
@Test
public void shouldGetArgumentTypes() {
SequenceType[] actualValue = transformationFunctionProxy.getArgumentTypes();
// TODO: assert scenario
}
}

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<records>
<oai:record xmlns="http://namespace.openaire.eu/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
xmlns:oaf="http://namespace.openaire.eu/oaf"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:prov="http://www.openarchives.org/OAI/2.0/provenance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<oai:header>
<dri:objIdentifier>od______2294::0000955eab68583ba0e07e973dd48708</dri:objIdentifier>
<dri:recordIdentifier>oai:pub.uni-bielefeld.de:1997560</dri:recordIdentifier>
<dri:dateOfCollection>2021-02-23T13:14:00.839Z</dri:dateOfCollection>
<oaf:datasourceprefix>od______2294</oaf:datasourceprefix>
<identifier xmlns="http://www.openarchives.org/OAI/2.0/">oai:pub.uni-bielefeld.de:1997560</identifier>
<datestamp xmlns="http://www.openarchives.org/OAI/2.0/">2018-07-24T12:58:03Z</datestamp>
<setSpec xmlns="http://www.openarchives.org/OAI/2.0/">journal_article</setSpec>
<setSpec xmlns="http://www.openarchives.org/OAI/2.0/">doc-type:article</setSpec>
</oai:header>
<metadata xmlns="http://www.openarchives.org/OAI/2.0/">
<resource xmlns="http://namespace.openaire.eu/schema/oaire/"
xmlns:datacite="http://datacite.org/schema/kernel-4"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xsi:schemaLocation="http://namespace.openaire.eu/schema/oaire/ https://www.openaire.eu/schema/repo-lit/4.0/openaire.xsd">
<datacite:title xml:lang="ger">Die antiken Grundlagen der europäischen Expansion. Eine epochenübergreifende kulturhistorische Unterrichtseinheit</datacite:title>
<datacite:creators>
<datacite:creator>
<datacite:creatorName nameType="Personal">Schulz, Raimund</datacite:creatorName>
</datacite:creator>
</datacite:creators>
<datacite:relatedIdentifiers>
<datacite:relatedIdentifier relatedIdentifierType="URL" relationType="HasMetadata">https://pub.uni-bielefeld.de/record/1997560.json</datacite:relatedIdentifier>
</datacite:relatedIdentifiers>
<datacite:alternateIdentifiers>
<datacite:alternateIdentifier alternateIdentifierType="ISSN">0016-9056</datacite:alternateIdentifier>
</datacite:alternateIdentifiers>
<dc:language>ger</dc:language>
<dc:publisher>Friedrich</dc:publisher>
<datacite:date dateType="Issued">2002</datacite:date>
<resourceType resourceTypeGeneral="literature" uri="http://purl.org/coar/resource_type/c_6501">journal article</resourceType>
<datacite:identifier identifierType="URL">https://pub.uni-bielefeld.de/record/1997560</datacite:identifier>
<datacite:rights rightsURI="http://purl.org/coar/access_right/c_14cb">metadata only access</datacite:rights>
<dc:source>Schulz R. Die antiken Grundlagen der europäischen Expansion. Eine epochenübergreifende kulturhistorische Unterrichtseinheit. <em>GWU</em>. 2002;53(5-/6):340-360.</dc:source>
<datacite:subjects/>
<licenseCondition uri="https://rightsstatements.org/page/InC/1.0/">In Copyright</licenseCondition>
<citationTitle>GWU</citationTitle>
<citationVolume>53</citationVolume>
<citationIssue>5-/6</citationIssue>
</resource>
</metadata>
<about xmlns="">
<provenance xmlns="http://www.openarchives.org/OAI/2.0/provenance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/provenance http://www.openarchives.org/OAI/2.0/provenance.xsd">
<originDescription altered="true" harvestDate="2021-02-23T13:14:00.839Z">
<baseURL>http%3A%2F%2Fpub.uni-bielefeld.de%2Foai</baseURL>
<identifier>oai:pub.uni-bielefeld.de:1997560</identifier>
<datestamp>2018-07-24T12:58:03Z</datestamp>
<metadataNamespace/>
</originDescription>
</provenance>
<oaf:datainfo>
<oaf:inferred>false</oaf:inferred>
<oaf:deletedbyinference>false</oaf:deletedbyinference>
<oaf:trust>0.9</oaf:trust>
<oaf:inferenceprovenance/>
<oaf:provenanceaction classid="sysimport:crosswalk:datasetarchive"
classname="sysimport:crosswalk:datasetarchive"
schemeid="dnet:provenanceActions" schemename="dnet:provenanceActions"/>
</oaf:datainfo>
</about>
</oai:record>
</records>

View File

@ -0,0 +1,374 @@
<!-- dc_cleaning_OPENAIREplus_compliant ; xslt language script widely used with specializations, production 2021-02-17 -->
declare_script "dc_cleaning_OpenAIREplus_compliant";
declare_ns oaf = "http://namespace.openaire.eu/oaf";
declare_ns dri = "http://www.driver-repository.eu/namespace/dri";
declare_ns dr = "http://www.driver-repository.eu/namespace/dr";
declare_ns dc = "http://purl.org/dc/elements/1.1/";
declare_ns prov = "http://www.openarchives.org/OAI/2.0/provenance";
declare_ns oai = "http://www.openarchives.org/OAI/2.0/";
declare_ns xs = "http://www.w3.org/2001/XMLSchema";
$var0 = "''";
$varFP7 = "'corda_______::'";
$varH2020 = "'corda__h2020::'";
$varAKA = "'aka_________::'"; // tbd, no statements yet
$varAFF = "'aff_________::'";
$varARC = "'arc_________::'";
$varCONICYT = "'conicytf____::'";
$varDFG = "'dfgf________::'";
$varFCT="'fct_________::'";
$varFWF = "'fwf_________::'";
$varGSRT = "'gsrt________::'";
$varHRZZ = "'irb_hr______::'";
$varINNOVIRIS = "'innoviris___::'";
$varMESTD = "'mestd_______::'";
$varMIUR = "'miur________::'"; // tbd, no statements yet
$varMZOS = "'irb_hr______::'";
$varNHMRC = "'nhmrc_______::'";
$varNIH = "'nih_________::'";
$varNSF = "'nsf_________::'";
$varNWO = "'nwo_________::'";
$varRCUK = "'rcuk________::'";
$varRIF = "'rif_________::'";
$varRSF = "'rsf_________::'";
$varSFI ="'sfi_________::'";
$varSGOV = "'sgov________::'";
$varSNSF = "'snsf________::'";
$varTARA = "'taraexp_____::'";
$varTUBITAK = "'tubitakf____::'";
$varWT = "'wt__________::'";
$varDummy = "''";
static $varDatasourceid = getValue(PROFILEFIELD, [xpath:"concat('collection(&amp;apos;/db/DRIVER/RepositoryServiceResources&amp;apos;)//RESOURCE_PROFILE[.//EXTRA_FIELDS/FIELD[key=&amp;quot;NamespacePrefix&amp;quot;][value=&amp;quot;', //oaf:datasourceprefix, '&amp;quot;]]')", xpath:"//EXTRA_FIELDS/FIELD[key='OpenAireDataSourceId']/value"]);
static $varRepoid = xpath:"//dri:repositoryId";
static $varOfficialname = getValue(PROFILEFIELD, [xpath:"concat('collection(&amp;apos;/db/DRIVER/RepositoryServiceResources&amp;apos;)//RESOURCE_PROFILE[.//EXTRA_FIELDS/FIELD[key=&amp;quot;NamespacePrefix&amp;quot;][value=&amp;quot;', //oaf:datasourceprefix, '&amp;quot;]]')", xpath:"//CONFIGURATION/OFFICIAL_NAME"]);
dri:objIdentifier = xpath:"//dri:objIdentifier";
dri:repositoryId = $varRepoid;
dri:recordIdentifier = xpath:"//dri:recordIdentifier";
// skip test records
if xpath:"//oaf:datasourceprefix[.='od______2659'] and //dc:title[lower-case(.) = 'popper test archive'] and //dc:creator[lower-case(.) = 'author, test'] and //dc:description[starts-with(lower-case(.), 'a short description of the article')]" dc:title = skipRecord(); else $varDummy= "''";
if xpath:"//oaf:datasourceprefix[.='od______2659'] and //dc:title[lower-case(.) = ('test doc', 'test_publish', 'test html', 'final_test')] and //dc:description = //dc:title" dc:title = skipRecord(); else $varDummy= "''";
if xpath:"count(//*[matches(., '^test(test|[\s\d,])*$', 'i')]) >= 2" dc:title = skipRecord(); else $varDummy= "''";
if xpath:"//oai:setSpec[.='col_data_1694'] or //dc:creator[starts-with(., 'test')]" dc:coverage = skipRecord(); else $varDummy = "''";
apply xpath:"//dc:creator[not(//oaf:datasourceprefix = 'od______4037')]" if xpath:"string-length(.) > 0 and not(contains(., 'US National Cancer Institute')) and normalize-space(.) != ','" dc:creator = xpath:"normalize-space(.)"; else $varDummy = "''";
apply xpath:"//dc:creator[//oaf:datasourceprefix = 'od______4037']" if xpath:"string-length(.) > 0 and normalize-space(.) != ',' and normalize-space(.)!='()'" dc:creator = xpath:"normalize-space(replace(., '^((.|\s)*)\((.|\s)*\)\s*', '$1'))"; else $varDummy = "''";
if xpath:"//dc:title[string-length(.)> 0] and not(//dc:creator[.='Test'])" $varDummy = "''"; else dc:coverage = skipRecord();
apply xpath:"//dc:title" if xpath:"string-length(.) > 0" dc:title = xpath:"normalize-space(.)"; else $varDummy = "''";
//
//apply xpath:"//dc:subject" if xpath:"string-length(.) > 0" dc:subject = xpath:"normalize-space(.)"; else $varDummy = "''";
//
// subject
// gather subjects: from fields setSpec, subject, classification, keywords
// assign context: if field value or @xsi:type refers to an approved vocabulary/classification/thesaurus, assign its normed code
// normalise form: in case of approved vocabulary/classification/thesaurus: 'context:subject', otherwise: 'subject [additional information]'
// remove duplicates: identical pairs of value/term and context/vocabulary
$subjVocHarv = xpath:"'agrovoc','acm','bicssc','bk','ddc','gok','jel classification','jel codes','jelelement','jel','lcsh','mesh','msc','pacs','rvk','udc'"; // subject contexts/vocabularies as harvested
$subjVocCode = xpath:"'agrovoc','ccs','bicssc','bk','ddc','gok','jel', 'jel', 'jel', 'jel','lcsh','mesh','msc','pacs','rvk','udc'"; // subject contexts/vocabularies as normed within OpenAIRE
$subjVoc = xpath:"concat('(',string-join($subjVocHarv,'|'),')')"; // regular expression for subject contexts
//$subjVocVal = xpath:"concat('^\s*','((info:eu-repo/classification/)?',$subjVoc,'[:/].*)')"; // regular expression for subject contexts in field values
$subjVocVal = xpath:"concat('^\s*','((info:eu-repo/classification/|http://www.ncbi.nlm.nih.gov/|http://aims.fao.org/aos/)?',$subjVoc,'[:/].*)')"; // regular expression for subject contexts in field values
$subjVocPar = xpath:"concat('^\s*','(dcterms:\s*)?',$subjVoc,'\s*$')"; // regular expression for subject contexts in field parameters
// subject context: approved vocabulary/classification/thesaurus in field value
//dc:subject = set(xpath:"(//dc:subject|//*[local-name()='setSpec'])[string-length(.) > 0 and matches(., $subjVocVal,'i')]", @classid=xpath:"subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(.),$subjVocVal,'$3','i')),1)";, @classname=xpath:"subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(.),$subjVocVal,'$3','i')),1)";, @schemeid=xpath:"'dnet:subject_classification_typologies'";, @schemename=xpath:"'dnet:subject_classification_typologies'";);
//$subjListInVal = xpath:"(//dc:subject|//*[local-name()='setSpec'])[string-length(.) > 0 and matches(., $subjVocVal,'i')]/concat(./subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(.),$subjVocVal,'$3','i')),1),':',normalize-space(replace(.,'(info:eu-repo/classification/)?([^/:]*)[:/](.*)','$3')))";
$subjListInVal = xpath:"(//dc:subject|//*[local-name()='setSpec'])[string-length(.) > 0 and matches(., $subjVocVal,'i')]/concat(./subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(.),$subjVocVal,'$3','i')),1),':',normalize-space(replace(.,'(info:eu-repo/classification/|http://www.ncbi.nlm.nih.gov/|http://aims.fao.org/aos/)?([^/:]*)[:/](.*)','$3')))";
// subject context: approved vocabulary/classification/thesaurus in field parameter
//dc:subject = set(xpath:"(//dc:subject|//*[local-name()='classification'])[string-length(.) > 0 and matches(./@xsi:type, $subjVocPar,'i')]", @classid=xpath:"subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(./@xsi:type),$subjVocPar,'$2','i')),1)";, @classname=xpath:"subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(./@xsi:type),$subjVocPar,'$2','i')),1)";, @schemeid=xpath:"'dnet:subject_classification_typologies'";, @schemename=xpath:"'dnet:subject_classification_typologies'";);
$subjListInPar = xpath:"(//dc:subject|//*[local-name()='classification'])[string-length(.) > 0 and matches(./@xsi:type, $subjVocPar,'i')]/concat(./subsequence($subjVocCode,index-of($subjVocHarv,replace(lower-case(./@xsi:type),$subjVocPar,'$2','i')),1),':',normalize-space(.))";
// subject context: approved vocabulary/classification/thesaurus in field value or parameter
$subjListInParAndVal = xpath:"distinct-values(insert-before($subjListInVal,0,$subjListInPar))";
dc:subject = set(xpath:"$subjListInParAndVal", @classid=xpath:"substring-before(.,':')";, @classname=xpath:"substring-before(.,':')";, @schemeid=xpath:"'dnet:subject_classification_typologies'";, @schemename=xpath:"'dnet:subject_classification_typologies'";);
// subject context: no (approved) vocabulary/classification/thesaurus
//dc:subject = set(xpath:"(//dc:subject|//*[local-name()='classification']|//*[local-name()='keywords'])[string-length(.) > 0 and not(matches(., $subjVocVal,'i')) and not(matches(./@xsi:type,$subjVocPar,'i'))]", @classid=xpath:"'keyword'";, @classname=xpath:"'keyword'";, @schemeid=xpath:"'dnet:result_subject'";, @schemename=xpath:"'dnet:result_subject'";);
//$subListKeywords = xpath:"distinct-values((//dc:subject|//*[local-name()='classification']|//*[local-name()='keywords'])[string-length(.) > 0 and not(matches(., $subjVocVal,'i')) and not(matches(./@xsi:type,$subjVocPar,'i'))]/replace(concat(normalize-space(replace(.,'((info:eu-repo/classification/[^/]*/)|([^:]*:))(.*)','$4')),' [',normalize-space(concat(replace(./@xsi:type,'dcterms:',''),' ',substring-before(replace(.,'(info:eu-repo/classification/)?([^/:]*)[/:](.*)','$2:$3'),':'))),']'),' \[\]',''))";
$subjListKeywordsInfo = xpath:"(//dc:subject|//*[local-name()='classification']|//*[local-name()='keywords'])[string-length(.) > 0 and not(matches(., $subjVocVal,'i')) and not(matches(./@xsi:type,$subjVocPar,'i')) and starts-with(.,'info:eu-repo/classification/')]
/replace(concat(normalize-space(replace(.,'info:eu-repo/classification/[^/]*/(.*)','$1')),' [',normalize-space(concat(replace(./@xsi:type,'dcterms:',''),' ',replace(.,'info:eu-repo/classification/([^/]*)/.*','$1'))),']'),' \[\]','')";
$subjListKeywordsColon = xpath:"(//dc:subject|//*[local-name()='classification']|//*[local-name()='keywords'])[string-length(.) > 0 and not(matches(., $subjVocVal,'i')) and not(matches(./@xsi:type,$subjVocPar,'i')) and not(starts-with(.,'info:eu-repo/classification/'))]/replace(concat(normalize-space(replace(.,'[^:]*:(.*)','$1')),' [',normalize-space(concat(replace(./@xsi:type,'dcterms:',''),' ',substring-before(.,':'))),']'),' \[\]','')";
$subjListKeywordsInfoAndColon = xpath:"distinct-values(insert-before($subjListKeywordsInfo,0,$subjListKeywordsColon))";
dc:subject = set(xpath:"$subjListKeywordsInfoAndColon", @classid=xpath:"'keyword'";, @classname=xpath:"'keyword'";, @schemeid=xpath:"'dnet:result_subject'";, @schemename=xpath:"'dnet:result_subject'";);
//
apply xpath:"//dc:publisher" if xpath:"string-length(.) > 0" dc:publisher = xpath:"normalize-space(.)"; else $varDummy = "''";
apply xpath:"//dc:source" if xpath:"string-length(.) > 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
dc:contributor = xpath:"//dc:contributor";
dc:description = xpath:"string-join(//dc:description[concat(normalize-space(.), '')], codepoints-to-string(10))";
$varHttpTest = "''";
//if xpath:"//dc:identifier[starts-with(normalize-space(.), 'http')][not(starts-with(., 'http://hdl.handle.net/123456789') or starts-with(., 'https://hdl.handle.net/123456789'))]" $varHttpTest = "true"; else dc:identifier = skipRecord();
//apply xpath:"//dc:identifier" if xpath:"starts-with(normalize-space(.), 'http')" dc:identifier = xpath:"normalize-space(.)"; else dr:CobjIdentifier = xpath:"normalize-space(.)";
dr:dateOfCollection = xpath:"//dri:dateOfCollection";
static dr:dateOfTransformation = xpath:"current-dateTime()";
dc:type = xpath:"//dc:type";
dc:format = xpath:"//dc:format";
dc:date = xpath:"distinct-values(//dc:date)";
dc:language = Convert(xpath:"//dc:language", Languages);
//dc:language = "eng";
//if xpath:"//dc:rights[text()='info:eu-repo/semantics/openAccess']" dc:publisher = xpath:"//dc:publisher"; else dc:publisher = skipRecord();
$varDateAccepted = Convert(xpath:"descendant-or-self::dc:date", DateISO8601, "yyyy-MM-dd", "min()");
if xpath:"//oaf:datasourceprefix[.='od_______883']" oaf:dateAccepted = Convert(xpath:"descendant-or-self::dc:date[3]", DateISO8601); else $varDummy= "''";
if xpath:"//oaf:datasourceprefix[.='od______3063']" oaf:dateAccepted = Convert(xpath:"descendant-or-self::dc:date", DateISO8601); else $varDummy= "''";
if xpath:"(//oaf:datasourceprefix[.='od______2658'] or //oaf:datasourceprefix[.='od______1318']) and starts-with($varDateAccepted, '1000')" oaf:dateAccepted = $varDummy; else $varDummy= "''";
if xpath:"not(//oaf:datasourceprefix[.='od_______883']) and not(//oaf:datasourceprefix[.='od______3063']) and not(starts-with($varDateAccepted, '10') or starts-with($varDateAccepted, '00'))" oaf:dateAccepted = $varDateAccepted; else $varDummy= "''";
// apply xpath:"//dc:date" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/date')" oaf:embargoenddate = RegExpr(xpath:"normalize-space(.)", $var0, "s/^(.*info:eu-repo\/date\/embargoEnd\/)//gmi"); else $var0 = "''";
$varEmbargoEnd = xpath:"distinct-values(//dc:date[matches(normalize-space(.), '(.*)(info:eu-repo/date/embargoEnd/)(\d\d\d\d-\d\d-\d\d)', 'i')][contains(lower-case(.), 'info:eu-repo')]/replace(normalize-space(.), '(.*)(info:eu-repo/date/embargoEnd/)(\d\d\d\d-\d\d-\d\d)', '$3', 'i'))";
oaf:embargoenddate = $varEmbargoEnd;
// --- projects ---
// FP7
oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i')][year-from-date(xs:date(max(($varDateAccepted, '0001-01-01')))) gt 2006][contains(lower-case(.), 'info:eu-repo')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/fp7/)(\d\d\d\d\d\d)(.*)', '$3', 'i')))";
// ERC (provided by OAPEN)
oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european research council.*/-/)(\d\d\d\d\d\d)(.*)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european research council.*/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i')))";
oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european union.* seventh framework programme.*/-/)(\d\d\d\d\d\d)(.*)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european union.* seventh framework programme.*/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i')))";
// H2020
oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i')][year-from-date(xs:date(max(($varDateAccepted, '0001-01-01')))) gt 2013][contains(lower-case(.), 'info:eu-repo')]/concat($varH2020, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/h2020/)(\d\d\d\d\d\d)(.*)', '$3', 'i')))";
// AFF
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(info:eu-repo/grantagreement/aff)/(.*)/(\d{3}\.?\d{2,3})', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varAFF, replace(normalize-space(.), '(info:eu-repo/grantagreement/aff)/(.*)/(\d{3}\.?\d{2,3}).*', '$3', 'i'))";
// AKA \d*
oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/aka/[^/]*/(\d+)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varAKA, replace(normalize-space(.), 'info:eu-repo/grantagreement/aka/[^/]*/(\d+)(/.*)?', '$1', 'i')))";
// ARC ([A-Z]+[\d/]*|\d+)
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(info:eu-repo/grantagreement/arc)/(.*)/([A-Z]+[\d/]*|\d+)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varARC, replace(normalize-space(.), '(info:eu-repo/grantagreement/arc)/(.*?)/([A-Z]+[\d/]*|\d+)', '$3', 'i'))";
// CONICYT \d{7,8}
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/conicyt/.*/.*?(\d{7,8})', 'i')]/concat($varCONICYT, replace(normalize-space(.), 'info:eu-repo/grantagreement/conicyt/.*/.*?(\d{7,8})', '$1', 'i'))";
// DFG \d{7,9}
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(info:eu-repo/grantagreement/dfg)/(.*)/(.*?)(\d{7,9})', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varDFG, replace(normalize-space(.), '(info:eu-repo/grantagreement/dfg)/(.*?)/.*?(\d{7,9})', '$3', 'i'))";
// FCT (SFRH/BD/)(\d+)(/\d+) ... ((SFRH|PRAXIS XXI|PD|FMRH)/[A-Z]*/)?\d*(/\d*)? ...
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/fct/[^/]*/[^/]+', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varFCT, replace(normalize-space(.), 'info:eu-repo/grantagreement/fct/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// FWF [A-Z]{1,3} \d*
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/fwf/[^/]*/.*?([A-Z]{1,3} \d*).*', 'i')]/concat($varFWF, replace(normalize-space(.), 'info:eu-repo/grantagreement/fwf/[^/]*/.*?([A-Z]{1,3} \d*).*', '$1', 'i'))";
// GSRT
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/gsrt/[^/]*/[^/]+', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varGSRT, replace(normalize-space(.), 'info:eu-repo/grantagreement/gsrt/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// HRZZ info:eu-repo/grantagreement/HRZZ/[^/]*/([^/]*|[^/]*/\d*)(/.*)?
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/hrzz/[^/]*/([^/]*|[^/]*/\d*)(/[^\d].*)?', 'i')]/concat($varHRZZ, replace(normalize-space(.), 'info:eu-repo/grantagreement/hrzz/[^/]*/([^/]*|[^/]*/\d*)(/[^\d].*)?', '$1', 'i'))";
// INNOVIRIS
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/innoviris/[^/]*/[^/]+', 'i')]/concat($varINNOVIRIS, replace(normalize-space(.), 'info:eu-repo/grantagreement/innoviris/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// MESTD \d*
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/mestd/[^/]*/\d+', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varMESTD, replace(normalize-space(.), 'info:eu-repo/grantagreement/mestd/[^/]*/(\d+)(/.*)?', '$1', 'i'))";
// MESTD
//oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(info:eu-repo/grantagreement/mestd)/(.+)/(\d+)(.*)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varMESTD, replace(normalize-space(.), '(info:eu-repo/grantagreement/mestd)/(.+)/(\d+)(.*)', '$3', 'i'))";
// MIUR [A-Z0-9]*
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/miur/[^/]*/.*?[A-Z0-9]*', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varMIUR, replace(normalize-space(.), 'info:eu-repo/grantagreement/miur/[^/]*/.*?([A-Z0-9]*).*?', '$1', 'i'))";
// MZOS \d{3}-\d{7}-\d{4}
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/mzos/[^/]*/.*?(\d{3}-\d{7}-\d{4})', 'i')]/concat($varMZOS, replace(normalize-space(.), 'info:eu-repo/grantagreement/mzos/[^/]*/.*?(\d{3}-\d{7}-\d{4}).*', '$1', 'i'))";
// NHMRC \d{3,6}
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/nhmrc/.*/.*?(\d{3,6})', 'i')]/concat($varNHMRC, replace(normalize-space(.), 'info:eu-repo/grantagreement/nhmrc/.*/.*?(\d{3,6})', '$1', 'i'))";
// NIH ([A-Z\d]*-[A-Z\d]*|ALM 1200300-300-0-1|CIT S&amp;?SF-0-0-1|[A-Z\d]{10}\*[5-7]-0-0-1) ... hm
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/nih/[^/]*/[^/]+', 'i')]/concat($varNIH, replace(normalize-space(.), 'info:eu-repo/grantagreement/nih/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// NSF (\d{7}|\d{2}[A-Z]\d{4})
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/nsf/[^/]*/[^/]+', 'i')]/concat($varNSF, replace(normalize-space(.), 'info:eu-repo/grantagreement/nsf/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// NWO
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/nwo/[^/]*/[^/]+', 'i')]/concat($varNWO, replace(normalize-space(.), 'info:eu-repo/grantagreement/nwo/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// RCUK
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/rcuk/[^/]*/[^/]+', 'i')]/concat($varRCUK, replace(normalize-space(.), 'info:eu-repo/grantagreement/rcuk/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// RIF
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/rif/[^/]*/[^/]+', 'i')]/concat($varRIF, replace(normalize-space(.), 'info:eu-repo/grantagreement/rif/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// RSF
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/rsf/[^/]*/[^/]+', 'i')]/concat($varRSF, replace(normalize-space(.), 'info:eu-repo/grantagreement/rsf/[^/]*/([^/]+)(/.*)?$', '$1', 'i'))";
// SFI
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/sfi/[^/]*/[^/]+', 'i')]/concat($varSFI, replace(normalize-space(.), 'info:eu-repo/grantagreement/sfi/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// SGOV
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/sgov/[^/]*/[^/]+', 'i')]/concat($varSGOV, replace(normalize-space(.), 'info:eu-repo/grantagreement/sgov/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// SNSF
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/snsf/[^/]*/[^/]+', 'i')]/concat($varSNSF, replace(normalize-space(.), 'info:eu-repo/grantagreement/snsf/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// TARA
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/tara/[^/]*/[^/]+', 'i')]/concat($varTARA, replace(normalize-space(.), 'info:eu-repo/grantagreement/tara/[^/]*/([^/]+)(/.*)?', '$1', 'i'))";
// TUBITAK
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), 'info:eu-repo/grantagreement/tubitak/[^/]*/\d{3}[A-Z]\d{2,3}', 'i')]/concat($varTUBITAK, replace(normalize-space(.), 'info:eu-repo/grantagreement/tubitak/[^/]*/(\d{3}[A-Z]\d{2,3})(/.*)?', '$1', 'i'))";
// WT
//oaf:projectid = xpath:"distinct-values(//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varWT, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i')))";
// WT
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', 'i')][contains(lower-case(.), 'info:eu-repo')]/concat($varWT, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
//dc:relation = xpath:"//dc:relation";
dc:relation = xpath:"//dc:relation[not(contains(., 'info:eu-repo/semantics/altIdentifier/') and substring-before(substring-after(., 'info:eu-repo/semantics/altIdentifier/'), '/') = ('ark', 'arxiv', 'doi', 'hdl', 'isbn', 'urn', 'pmid', 'wos', 'issn', 'eissn', 'url'))][count(index-of(($varIdDoi//value, $varIdDoiNonStd//value), replace(., '(info:doi:|doi:|info:doi/|https?://(dx.)?doi.org/)', ''))) = 0]";
dc:relation = xpath:"subsequence(distinct-values(($varIdDoi//value, $varIdDoiNonStd//value)), 2)";
//comment-js-09-10-2012 apply xpath:"//dc:rights" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/semantics')" dc:rights = empty; else dc:rights = xpath:"normalize-space(.)";
//
//
oaf:collectedDatasourceid = xpath:"$varDatasourceid";
//
// dr:CobjCategory = Convert(xpath:"//dc:type", TextTypologies);
// if xpath:"//dc:type[1]/lower-case(.) = 'text'" dr:CobjCategory = Convert(xpath:"reverse(//dc:type)", TextTypologies); else dr:CobjCategory = Convert(xpath:"//dc:type", TextTypologies);
// if xpath:"//dc:type[1]/lower-case(.) = ('text', 'info:eu-repo/semantics/other', 'other') or //oaf:datasourceprefix/lower-case(.) = 'openedition_'" dr:CobjCategory = Convert(xpath:"reverse(//dc:type | //oai:setSpec)", TextTypologies); else dr:CobjCategory = Convert(xpath:"//dc:type | //oai:setSpec", TextTypologies);
$varCobjCategoryReverse = Convert(xpath:"insert-before(reverse(//dc:type) , 0, reverse(//oai:setSpec))", TextTypologies);
$varSuperTypeReverse = Convert(xpath:"normalize-space($varCobjCategoryReverse)", SuperTypes);
dr:CobjCategory = set(xpath:"//oaf:datasourceprefix[//dc:type[1]/lower-case(.) = ('text', 'info:eu-repo/semantics/other', 'other') or //oaf:datasourceprefix/lower-case(.) = 'openedition_']/$varCobjCategoryReverse", @type = $varSuperTypeReverse;);
$varCobjCategoryStraight = Convert(xpath:"insert-before(//dc:type , 100, //oai:setSpec)", TextTypologies);
$varSuperTypeStraight = Convert(xpath:"normalize-space($varCobjCategoryStraight)", SuperTypes);
dr:CobjCategory = set(xpath:"//oaf:datasourceprefix[not(//dc:type[1]/lower-case(.) = ('text', 'info:eu-repo/semantics/other', 'other') or //oaf:datasourceprefix/lower-case(.) = 'openedition_') and (not(//oaf:datasourceprefix/lower-case(.) = 'od________65'))]/$varCobjCategoryStraight", @type = $varSuperTypeStraight;);
// CERN CDS when dc:type or setSpec explicitly states resource type
// (currently :CONF not covered as not included in vocabulary, and as landing in literature already; other sets might also be addressed, depending on marked resource types)
$varCobjCategoryCernExplicit = Convert(xpath:"normalize-space((//dc:type, //*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT')]/tokenize(., ':')[2])[1])", TextTypologies);
$varSuperTypeCernExplicit = Convert(xpath:"normalize-space($varCobjCategoryCernExplicit)", SuperTypes);
dr:CobjCategory = set(xpath:"//oaf:datasourceprefix[//oaf:datasourceprefix = 'od________65' and (//dc:type or //*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT')])]/$varCobjCategoryCernExplicit", @type = $varSuperTypeCernExplicit;);
// CERN CDS when set vaguely hints on literature
$varCobjCategoryCernVague = xpath:"//oaf:datasourceprefix[not(//*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT')]) and //*[local-name() = 'setSpec'][ends-with(., ':FULLTEXT')]]/'0038'";
$varSuperTypeCernVague = Convert(xpath:"normalize-space($varCobjCategoryCernVague)", SuperTypes);
dr:CobjCategory = set(xpath:"//oaf:datasourceprefix[//oaf:datasourceprefix = 'od________65' and not(//dc:type) and not(//*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT')])]/$varCobjCategoryCernVague", @type = $varSuperTypeCernVague;);
// CERN CDS when no hint
$varCobjCategoryCernUnknown = xpath:"//oaf:datasourceprefix[not(//dc:type) and not(//*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT') or ends-with(., ':FULLTEXT')])]/'0000'";
$varSuperTypeCernUnknown = Convert(xpath:"normalize-space($varCobjCategoryCernUnknown)", SuperTypes);
dr:CobjCategory = set(xpath:"//oaf:datasourceprefix[//oaf:datasourceprefix = 'od________65' and not(//dc:type) and not(//*[local-name() = 'setSpec'][contains(., ':BOOK') or contains(., ':REPORT')])]/$varCobjCategoryCernUnknown", @type = $varSuperTypeCernUnknown;);
//
// review status
$varRefereedConvt = Convert(xpath:"(//dc:type, //oai:setSpec, //dc:description)", ReviewLevels);
$varRefereedReltn = xpath:"//*[string(node-name(.)) = 'dc:relation' and matches(lower-case(normalize-space(.)), 'doi\s*:?\s*10.24072/.+')]/'0001'";
//$varRefereedProse = xpath:"//*[string(node-name(.)) = 'dc:description' and matches(lower-case(.), '(this|a)\s*(article|preprint)\s*(has\s*been\s*)?(peer[\-\s]*)?reviewed\s*and\s*recommended\s*by\s*peer[\-\s]*community') and contains(., '10.24072/')]/'0001'";
$varRefereedDesct = xpath:"(//dc:description[matches(lower-case(.), '.*(this\s*book|this\s*volume|it)\s*constitutes\s*the\s*(thoroughly\s*)?refereed') or matches(lower-case(.), '.*peer[\.\-_/\s\(\)]?review\s*under\s*responsibility\s*of.*') or matches(lower-case(.), '(this|a)\s*(article|preprint)\s*(has\s*been\s*)?(peer[\-\s]*)?reviewed\s*and\s*recommended\s*by\s*peer[\-\s]*community')]/'0001', //dc:description[matches(., '^version\s*(préliminaire.*|preliminary.*|0$)')]/'0002')";
$varRefereedTitle = xpath:"//dc:title[matches(lower-case(.), '.*\[.*peer[\s\-\._]*review\s*:.*\]\s*$')]/'0001'";
$varRefereedSourc = xpath:"//*[string(node-name(.)) = ('dc:source', 'dc:publisher') and matches(lower-case(.), '^(.*\s)?pre[\s\-_]*prints?([\s\.,].*)?$')]/'0002'";
//$varRefereedIdntf = xpath:"(//*[string(node-name(.)) = 'dc:relation' and matches(lower-case(.), '^info:eu-repo/semantics/altidentifier/doi/10\..*[\.\-_/\s\(\)]pre[\.\-_/\s\(\)]?prints?([\.\-_/\s\(\)].*)?$')], //*[string(node-name(.)) = 'dc:identifier' and matches(lower-case(.), '(^|.*[\.\-_/\s\(\)])pre[\.\-_/\s\(\)]?prints?([\.\-_/\s\(\)].*)?$')])/'0002'";
$varRefereedIdntf = xpath:"(//*[string(node-name(.)) = 'dc:identifier' and matches(lower-case(.), '(^|.*[\.\-_/\s\(\)%\d#])pre[\.\-_/\s\(\)%\d#]?prints?([\.\-_/\s\(\)%\d#].*)?$')][count(//dc:identifier) = 1]/'0002', //*[string(node-name(.)) = 'dc:identifier' and matches(lower-case(.), '(^|.*[\.\-_/\s\(\)%\d#])refereed([\.\-_/\s\(\)\d%\d#].*)?$')]/'0001', //*[string(node-name(.)) = 'dc:identifier' and matches(lower-case(.), '.*-peer-reviewed-(fulltext-)?article-.*')]/'0001')";
$varRefereed = xpath:"($varRefereedConvt, $varRefereedReltn, $varRefereedDesct, $varRefereedTitle, $varRefereedSourc, $varRefereedIdntf)";
if xpath:"count(index-of($varRefereed, '0001')) >0" oaf:refereed = xpath:"'0001'"; else $varDummy= "''";
if xpath:"count(index-of($varRefereed, '0002')) >0 and count(index-of($varRefereed, '0001')) = 0" oaf:refereed = xpath:"'0002'"; else $varDummy= "''";
//
if xpath:"(xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) gt current-date()) and not(//oaf:datasourceprefix = 'od_______151')" oaf:accessrights = "EMBARGO"; else $var0 = "''";
if xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics') and not(starts-with(normalize-space(.), 'info:eu-repo/semantics/embargo')) and not((xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) gt current-date()))] or (//oaf:datasourceprefix = 'od_______151')" oaf:accessrights = Convert(xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics')]", AccessRights); else $var0 = "''";
if xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics/embargo') and not((xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) gt current-date()))] and not(//oaf:datasourceprefix = 'od_______151')" oaf:accessrights = "OPEN"; else $var0 = "''";
if xpath:"count(//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics/')]) eq 0 and not($varDatasourceid = ('opendoar____::3532', 'opendoar____::109', 'opendoar____::151'))" oaf:accessrights = "OPEN"; else $var0 = "''";
//
// apply xpath:"//dc:rights" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/semantics') and (xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) gt current-date())" oaf:accessrights = Convert(xpath:"normalize-space(.)", AccessRights); else dc:rights = xpath:".";
// apply xpath:"//dc:rights" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/semantics') " oaf:accessrights = Convert(xpath:"normalize-space(.)", AccessRights); else dc:rights = xpath:".";
// if xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics/restrictedAccess') ]" oaf:accessrights = "RESTRICTED"; else $var0 = "''";
// if xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics') and not(xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) lt current-date())]" $var0 = "''"; else oaf:accessrights = "OPEN";
// oaf:accessrights = xpath:"//dc:rights[ not(starts-with(normalize-space(.), 'info:eu-repo/semantics')) and xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) lt current-date()]/concat('OPEN')";
// oaf:accessrights = xpath:"//dc:rights[not(contains(normalize-space(.), 'info:eu-repo/semantics'))]/normalize-space('OPEN')";
// oaf:accessrights = xpath:"not(xs:date( max( ($varEmbargoEnd, '0001-01-01') ) ) lt current-date())";
//
if xpath:"$varDatasourceid = 'opendoar____::3532' and //dc:format = 'fulltext'" oaf:accessrights = "OPEN"; else $var0 = "''";
if xpath:"$varDatasourceid = 'opendoar____::3532' and //dc:format = 'abstractOnly'" oaf:accessrights = "CLOSED"; else $var0 = "''";
if xpath:"$varDatasourceid = 'opendoar____::3532' and not(//dc:format = ('fulltext', 'abstractOnly'))" oaf:accessrights = "UNKNOWN"; else $var0 = "''";
if xpath:"$varDatasourceid = 'opendoar____::109'" oaf:accessrights = Convert(xpath:"normalize-space(//dc:rights[starts-with(., 'http')][1])", AccessRights); else $var0 = "''";
if xpath:"$varDatasourceid = 'openaire____::paho_covid19' and //dc:identifier[ends-with(., 'pdf')]" oaf:fulltext = xpath:"//dc:identifier[ends-with(., 'pdf')]"; else $var0 = "''";
oaf:license = xpath:"//dc:rights[contains (., 'http://creativecommons.org/licenses/') or contains(., 'http://opensource.org/licenses/')]";
static oaf:collectedFrom = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
static oaf:hostedBy = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
//
//$varId = identifierExtract('["//dc:identifier", "//dc:relation"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
//$varId = identifierExtract('["//dc:identifier", "//dc:relation[not(//*[local-name() = \"datasourceprefix\" and .=\"od______1859\"])]"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
$varIdDoi = identifierExtract('["//dc:identifier[starts-with(normalize-space(.), \"info:\") or starts-with(normalize-space(.), \"urn:\") or starts-with(normalize-space(.), \"doi:\") or starts-with(normalize-space(.), \"DOI:\") or starts-with(normalize-space(.), \"10.\") or ((starts-with(normalize-space(.), \"http\") or starts-with(normalize-space(.), \"PURE LINK: http\")) and contains(., \"doi.org/10.\"))]", "//dc:relation[contains(., \"info:eu-repo/semantics/altIdentifier/doi/\") or contains(., \"info:eu-repo/semantics/altIdentifier/url/\")]"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
//$varIdDoiNonStd = identifierExtract('["//dc:relation[not(contains(., \"info:eu-repo/semantics/altIdentifier/doi/\"))]"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
$varIdDoiNonStd = identifierExtract('["//dc:relation[not(contains(., \"info:eu-repo/semantics/altIdentifier/doi/\") or contains(., \"info:eu-repo/semantics/altIdentifier/url/\"))][starts-with(normalize-space(.), \"info:\") or starts-with(normalize-space(.), \"urn:\") or starts-with(normalize-space(.), \"doi:\") or starts-with(normalize-space(.), \"DOI:\") or starts-with(normalize-space(.), \"10.\") or ((starts-with(normalize-space(.), \"http\") or starts-with(normalize-space(.), \"PURE LINK: http\")) and contains(., \"doi.org/10.\"))]"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
// 1st param: list of xpath expresssions to be applied on the metadata in json syntax; 2nd param: xpath expression for the metadata record; 3rd param reg expr that matches with a negative lookahead for the first group and extracts digits of the second group
//$varHandle = xpath:"//dc:identifier[//oaf:datasourceprefix[.='od______2097'] and starts-with(., 'http://hdl.handle.net/')]/substring-after(., 'http://hdl.handle.net/')";
$varIdHdl = identifierExtract('["//dc:identifier[starts-with(., \"info:hdl:\") or ((starts-with(., \"http\") or starts-with(., \"PURE LINK: http\") or starts-with(., \"URI:http\")) and contains(., \"://hdl.handle.net/\"))][not(contains(., \"123456789\"))]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/hdl/\") or (starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/url/\") and contains(., \"://hdl.handle.net/\"))]"]' , xpath:"./*[local-name()='record']" , '(?!(info:hdl:|://hdl.handle.net/|info:eu-repo/semantics/altIdentifier/hdl/))(\d.*)');
// $varUrn = xpath:"substring-after(//dc:relation[starts-with(normalize-space(.), 'info:eu-repo/semantics/altIdentifier/urn/')], 'info:eu-repo/semantics/altIdentifier/urn/')";
//$varUrn = identifierExtract('["//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/urn/\")]"]' , xpath:"./*[local-name()='record']" , '(?!info:eu-repo/semantics/altIdentifier/urn/)(urn:nbn:.*)');
$varIdUrn = identifierExtract('["//dc:identifier[starts-with(., \"urn:nbn:\") or starts-with(., \"URN:NBN:\") or ((starts-with(., \"http\") or starts-with(., \"PURE LINK: http\")) and (contains(., \"://nbn-resolving.org/urn:nbn:\") or contains(., \"://nbn-resolving.de/urn/resolver.pl?urn:nbn:\") or contains(., \"://resolver.obvsg.at/urn:nbn:\") or contains(., \"://urn.fi/URN:NBN:\")))]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/urn/\")]"]' , xpath:"./*[local-name()='record']" , '(?!(://nbn-resolving.org/|info:eu-repo/semantics/altIdentifier/urn/))((urn:nbn:|URN:NBN:).*)');
//$varIsbn = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2097'] and starts-with(., '978') or starts-with(., '979')]";
$varIdIsbn = identifierExtract('["//dc:identifier[starts-with(normalize-space(.), \"urn:isbn:\") or starts-with(normalize-space(.), \"urn:ISBN:\") or starts-with(normalize-space(.), \"isbn:\") or starts-with(normalize-space(.), \"ISBN:\") or (starts-with(., \"978-\") and (string-length(.) = 17 or string-length(normalize-space(substring-before(., \"(\"))) = 17))]", "//*[name() = \"dc:relation\" or name() = \"dc:identifier\"][starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/isbn/\")]","//dc:source[//*[local-name() = \"datasourceprefix\" and .=\"od______2097\"] and starts-with(., \"978\") or starts-with(., \"979\")]"]' , xpath:"./*[local-name()='record']" , '(?!(urn:isbn:|info:eu-repo/semantics/altIdentifier/isbn/))(97.*)');
$varIdIsrn = identifierExtract('["//dc:identifier[starts-with(., \"ISRN:\")]"]' , xpath:"./*[local-name()='record']" , '(ISRN:.+)');
$varIdEan = identifierExtract('["//dc:identifier[starts-with(., \"EAN13:\")]"]' , xpath:"./*[local-name()='record']" , '(EAN13:.+)');
$varIdArk = identifierExtract('["//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/ark/\")]"]' , xpath:"./*[local-name()='record']" , '(info.*)');
//$varPmId = identifierExtract('["//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/pmid/\")]"]' , xpath:"./*[local-name()='record']" , '(?!info:eu-repo/semantics/altIdentifier/pmid/)(\d+)');
$varIdPmId = identifierExtract('["//dc:identifier[((starts-with(., \"http\") or starts-with(., \"PURE LINK: http\")) and contains(., \"://www.ncbi.nlm.nih.gov/pmc/articles/\") and not(contains(., \"/pdf/\"))) or starts-with(., \"info:pmid/\") or starts-with(., \"PMID:\") or starts-with(., \"PubMed:\")]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/pmid/\") or (starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/url/http\") and contains(., \"://www.ncbi.nlm.nih.gov/pmc/articles/\") and not(contains(., \"/pdf/\")))]"]' , xpath:"./*[local-name()='record']" , '(?!(://www.ncbi.nlm.nih.gov/pmc/articles/|info:eu-repo/semantics/altIdentifier/pmid/))(\d+)');
$varIdPmc = identifierExtract('["//dc:identifier[starts-with(., \"PMCID:\") or starts-with(., \"pmc:\")]"]' , xpath:"./*[local-name()='record']" , '(PMC\d+)');
$varIdHal = identifierExtract('["//dc:identifier[starts-with(., \"hal-\") or starts-with(., \"halshs-\") or starts-with(., \"halsde-\")]"]' , xpath:"./*[local-name()='record']" , '(hal.*)');
$varIdBibc = identifierExtract('["//dc:identifier[starts-with(., \"BibCode:\")]"]' , xpath:"./*[local-name()='record']" , '(([\d\.]).*)');
$varIdArxv = identifierExtract('["//dc:identifier[((starts-with(., \"http\") or starts-with(., \"PURE LINK: http\") or starts-with(., \"ArXiv: http\")) and contains(., \"://arxiv.org/abs/\")) or starts-with(., \"arXiv:\")]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/arxiv/\") or (starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/url/http\") and contains(., \"://arxiv.org/abs/\"))]"]' , xpath:"./*[local-name()='record']" , '(?!(://arxiv.org/abs/|:eu-repo/semantics/altIdentifier/arxiv/))([a-zA-Z].*)');
$varIdWos = identifierExtract('["//dc:identifier[starts-with(., \"WOS:\")]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/wos/\")]"]' , xpath:"./*[local-name()='record']" , '(info.*|WOS:.+)');
$varIdScp = identifierExtract('["//dc:identifier[starts-with(normalize-space(.), \"SCOPUS_ID:\") or starts-with(normalize-space(.), \"Scopus:\") or ((starts-with(normalize-space(.), \"http\") or starts-with(normalize-space(.), \"PURE LINK: http\")) and contains(., \"://www.scopus.com/inward/record.ur\"))]"]' , xpath:"./*[local-name()='record']" , '(.+)');
$varIdLdpg = identifierExtract('["//dc:identifier[(contains(substring-after(., \"://\"), \"/\") and contains(//*[local-name() = \"baseURL\"], substring-before(substring-after(., \"://\"), \"/\"))) or (contains(substring-after(., \"://\"), \":\") and contains(//*[local-name() = \"baseURL\"], substring-before(substring-after(., \"://\"), \":\")))]"]', xpath:"./*[local-name()='record']" , '(http.*)');
//$varUrl = xpath:"//dc:identifier[//oaf:datasourceprefix[.='od______1859'] and starts-with(., 'http') and contains(., '/handle/')]";
//$varIdUrl = identifierExtract('["//dc:identifier[starts-with(normalize-space(.), \"http\")][not(contains(., \"doi.org/\")) and not(contains(., \"hdl.handle.net/\")) and not(contains(., \"://nbn-resolving.org/\")) and not(contains(., \".fr/hal-\")) and not(contains(., \".fr/halsde-\")) and not(contains(., \".fr/halshs-\")) and not(contains(., \"://arxiv.org/abs/\")) and not(contains(., \"://www.ncbi.nlm.nih.gov/pmc/articles/\"))]"]' , xpath:"./*[local-name()='record']" , '(http.*)');
$varIdUrl = identifierExtract('["//dc:identifier[starts-with(normalize-space(.), \"http\") or starts-with(normalize-space(.), \"url:http\") or starts-with(normalize-space(.), \"PURE ITEMURL: http\") or starts-with(normalize-space(.), \"PURE FILEURL: http\")][not(contains(., \"doi.org/\")) and not(contains(., \"hdl.handle.net/\")) and not(contains(., \"://nbn-resolving.org/\")) and not(contains(., \"://nbn-resolving.de/\")) and not(contains(., \"://resolver.obvsg.at/\")) and not(contains(., \".fr/hal-\")) and not(contains(., \".fr/halsde-\")) and not(contains(., \".fr/halshs-\")) and not(contains(., \"://arxiv.org/abs/\")) and not(contains(., \"://www.ncbi.nlm.nih.gov/pmc/articles/\"))]", "//dc:relation[starts-with(normalize-space(.), \"info:eu-repo/semantics/altIdentifier/url/http\")][not(contains(., \"doi.org/\")) and not(contains(., \"hdl.handle.net/\")) and not(contains(., \"://nbn-resolving.org/\")) and not(contains(., \"://nbn-resolving.de/\")) and not(contains(., \".fr/hal-\")) and not(contains(., \".fr/halsde-\")) and not(contains(., \".fr/halshs-\")) and not(contains(., \"://arxiv.org/abs/\")) and not(contains(., \"://www.ncbi.nlm.nih.gov/pmc/articles/\"))]"]' , xpath:"./*[local-name()='record']" , '(http.*)');
$varIdList = xpath:"(($varIdDoi//value, varIdDoiNonStd//value, $varIdHdl//value, $varIdUrn//value, $varIdIsbn//value, $varIdIsrn//value, $varIdEan//value, $varIdArk//value, $varIdPmId//value, $varIdPmc//value, $varIdHal//value, $varIdBibc//value, $varIdArxv//value, $varIdWos//value, $varIdScp//value, $varIdLdpg//value, $varIdUrl//value))";
$varIdUrlOrResolvableList = xpath:"(($varIdLdpg//value, $varIdUrl//value, $varIdDoi//value, varIdDoiNonStd//value, $varIdHdl//value, $varIdUrn//value, $varIdPmId//value, $varIdPmc//value, $varIdHal//value, $varIdArxv//value))";
if xpath:"count($varIdUrlOrResolvableList) > 0" $varHttpTest = "true"; else dc:identifier = skipRecord();
$varKnownFileEndings = xpath:"('.bmp', '.doc', '.docx', '.epub', '.flv', '.htm', '.html', '.jpeg', '.jpg', '.m4v', '.mp4', '.mpg', '.odp', '.pdf', '.png', '.ppt', '.tiv', '.txt', '.xls', '.xlsx', '.zip')";
dc:identifier = xpath:"$varIdUrlOrResolvableList[1]";
dr:CobjIdentifier = xpath:"distinct-values(//dc:identifier[not(starts-with(normalize-space(.), 'http') or starts-with(normalize-space(.), 'url:http') or starts-with(normalize-space(lower-case(.)), 'uri:http') or starts-with(normalize-space(.), 'PURE ITEMURL: http') or starts-with(normalize-space(.), 'PURE FILEURL: http') or starts-with(normalize-space(.), 'PURE LINK: http'))][not(normalize-space(.) = ($varIdList))][not(starts-with(normalize-space(.), 'info:doi:') or starts-with(normalize-space(lower-case(.)), 'doi:') or starts-with(normalize-space(.), 'info:doi/') or starts-with(normalize-space(.), 'info:eu-repo/semantics/altIdentifier/doi/'))][not(starts-with(normalize-space(.), 'info:hdl:'))][not(starts-with(normalize-space(lower-case(.)), 'urn:isbn:') or starts-with(normalize-space(lower-case(.)), 'isbn:') or starts-with(normalize-space(.), 'info:eu-repo/semantics/altIdentifier/isbn/'))][not(starts-with(normalize-space(.), 'urn:nbn:'))][not(starts-with(., 'info:pmid/') or starts-with(lower-case(.), 'pmid:') or starts-with(lower-case(.), 'pubmed:') or starts-with(lower-case(.), 'pmcid:') or starts-with(lower-case(.), 'pmc:'))][not(starts-with(lower-case(.), 'bibcode:'))][not(. = $varISSN[1]) and not(starts-with(lower-case(.), 'issn:') or starts-with(lower-case(.), 'urn:issn:'))][not(starts-with(., 'SCOPUS_ID:'))][not(starts-with(., 'oai:'))][normalize-space(.) != ''])";
//oaf:identifier = set(xpath:"$varId//value", @identifierType = "doi";);
oaf:identifier = set(xpath:"($varIdDoi//value[1], $varIdDoiNonStd[1]//value)[1]", @identifierType = "doi";);
//oaf:identifier = set(xpath:"$varHandle", @identifierType = "handle";);
oaf:identifier = set(xpath:"$varIdHdl//value", @identifierType = "handle";);
//oaf:identifier = set(xpath:"$varUrn//value", @identifierType = "urn";);
oaf:identifier = set(xpath:"$varIdUrn//value", @identifierType = "urn";);
//oaf:identifier = set(xpath:"$varIsbn", @identifierType = "isbn";);
oaf:identifier = set(xpath:"$varIdIsbn//value", @identifierType = "isbn";);
oaf:identifier = set(xpath:"$varIdIsrn//value/normalize-space(substring-after(., 'ISRN:'))", @identifierType = "isrn";);
oaf:identifier = set(xpath:"$varIdEan//value/normalize-space(substring-after(., 'EAN13:'))", @identifierType = "ean";);
oaf:identifier = set(xpath:"$varIdArk//value/substring-after(., 'info:eu-repo/semantics/altIdentifier/ark/')", @identifierType = "ark";);
//oaf:identifier = set(xpath:"$varPmId//value", @identifierType = "pmid";);
oaf:identifier = set(xpath:"$varIdPmId//value", @identifierType = "pmid";);
oaf:identifier = set(xpath:"$varIdPmc//value", @identifierType = "pmcid";);
oaf:identifier = set(xpath:"$varIdHal//value", @identifierType = "hal";);
oaf:identifier = set(xpath:"$varIdBibc//value", @identifierType = "bibcode";);
//oaf:identifier = set(xpath:"distinct-values(($varIdArxv//value[contains(., '://arxiv.org/abs/')]/substring-after(., '://arxiv.org/abs/'), $varIdArxv//value[contains(., 'info:eu-repo/semantics/altIdentifier/arxiv/')]/substring-after(., 'info:eu-repo/semantics/altIdentifier/arxiv/')))", @identifierType = "arxiv";);
oaf:identifier = set(xpath:"distinct-values(($varIdArxv//value/normalize-space(replace(., '(https?://arxiv.org/abs/|info:eu-repo/semantics/altIdentifier/arxiv/|info:eu-repo/semantics/altIdentifier/url/|arXiv:)', '', 'i'))))", @identifierType = "arxiv";);
oaf:identifier = set(xpath:"$varIdWos//value/normalize-space(replace(., '(info:eu-repo/semantics/altIdentifier/wos/|WOS:)', ''))", @identifierType = "wos";);
oaf:identifier = set(xpath:"distinct-values(($varIdScp//value/replace(normalize-space(.), '^((PURE LINK: )?https?://www.scopus.com/inward/record.ur.*(scp=|eid=2-s2.0-)|SCOPUS_ID:\s*|Scopus:\s*)(\d+).*$', '$4')))", @identifierType = "scp";);
oaf:identifier = set(xpath:"$varIdLdpg//value[not(replace(lower-case(.), '.*(\.[a-z]*)$', '$1') = $varKnownFileEndings)]", @identifierType = "landingPage";);
//oaf:identifier = set(xpath:"$varUrl", @identifierType = "url";);
oaf:identifier = set(xpath:"$varIdUrl//value[count(index-of($varIdLdpg//value, .)) = 0 or replace(lower-case(.), '.*(\.[a-z]*)$', '$1') = $varKnownFileEndings]", @identifierType = "url";);
oaf:datasourceprefix = xpath:"//oaf:datasourceprefix";
// journal data;
// PURE: exposes ISSN in field ns2:isPartOf, journal title not extractable due to ' usage in source field
//$varJournalTitle = xpath:"//dc:subject[1][//oaf:datasourceprefix[.='dovemedicalp']]/normalize-space(.), //dc:source[1][//oaf:datasourceprefix[.='scindeksserb']]/normalize-space(substring-before(., '('))";
//$varJournalTitle = xpath:"//dc:subject[1][//oaf:datasourceprefix[.='dovemedicalp']]/normalize-space(.), //dc:source[1][//oaf:datasourceprefix[.='scindeksserb']]/normalize-space(substring-before(., '(')), //dc:source[//oaf:datasourceprefix[.='od______2659']][//dc:relation[matches(., '(issn:|info:eu-repo/semantics/altIdentifier/issn/)','i')]]/normalize-space(replace(., '^(.*?)\s(\d|v\.\s\d).*$', '$1'))";
//$varJournalTitle = xpath:"//dc:subject[1][//oaf:datasourceprefix[.='dovemedicalp']]/normalize-space(.), //dc:source[1][//oaf:datasourceprefix[.='scindeksserb']]/normalize-space(substring-before(., '(')), //dc:source[//oaf:datasourceprefix[.='od______2659']][//dc:relation[matches(., '(issn:|info:eu-repo/semantics/altIdentifier/issn/)','i')]]/normalize-space(replace(., '^(.*?)\s(\d|v\.\s\d).*$', '$1')), //dc:source[//oaf:datasourceprefix[.='od______2097'] and //dc:source[matches(., '\d{4}-\d{3}[\dX]')] and not(matches(., '\d{4}-\d{3}[\dX]'))][1]";
$varJournalTitle = xpath:"//dc:subject[1][//oaf:datasourceprefix[.='dovemedicalp']]/normalize-space(.), //dc:source[1][//oaf:datasourceprefix[.='scindeksserb']]/normalize-space(substring-before(., '(')), //dc:source[//oaf:datasourceprefix[.='od______2659']][//dc:relation[matches(., '(issn:|info:eu-repo/semantics/altIdentifier/issn/)','i')]]/normalize-space(replace(., '^(.*?)\s(\d|v\.\s\d).*$', '$1')), //dc:source[//oaf:datasourceprefix[.='od______2097'] and //dc:source[matches(., '\d{4}-\d{3}[\dX]')] and not(matches(., '\d{4}-\d{3}[\dX]'))][1], //dc:source[1][//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and //dc:source[not(starts-with(., 'ISSN '))]]/replace(., '^(.*?)\.\s*\d{4}.*$', '$1'), //dc:source[//oaf:datasourceprefix[.='issn22953671'] and //dc:source[matches(., '\d{4}-\d{3}[\dX]')] and not(matches(., '\d{4}-\d{3}[\dX]'))][1]/substring-before(., ';')";
//$varISSN = xpath:"//oai:setSpec[starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:')]/normalize-space(substring-after(., 'ISSN:'))";
//$varISSN = xpath:"//*[local-name()='setSpec'][starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:')]/normalize-space(substring-after(., 'ISSN:')), //dc:relation[starts-with(., 'issn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/issn/')]/replace(normalize-space(substring-after(., 'issn')),'[/:]([0-9]{4})-?([0-9X]{4})','$1-$2')";
//$varISSN = xpath:"//*[local-name()='setSpec'][starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:')]/normalize-space(substring-after(., 'ISSN:')), //dc:relation[starts-with(., 'issn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/issn/')]/replace(normalize-space(substring-after(., 'issn')),'[/:]([0-9]{4})-?([0-9X]{4})','$1-$2'), //dc:source[//oaf:datasourceprefix='issn20381026'][matches(.,'\d\d\d\d-\d\d\d\d')][1], //dc:identifier[//oaf:datasourceprefix[.='od______3636'] and matches(., '[0-9]{4}-[0-9]{3}[0-9X]')], //dc:source[//oaf:datasourceprefix[.='od______2097'] and matches(., '\d{4}-\d{3}[\dX]')]";
//$varISSN = xpath:"//*[local-name()='setSpec'][starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:') or starts-with(., 'ISSN ')]/normalize-space(replace(., 'ISSN[:\s](.*)$', '$1')), //dc:relation[starts-with(., 'issn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/issn/')]/replace(normalize-space(substring-after(., 'issn')),'[/:]([0-9]{4})-?([0-9X]{4})','$1-$2'), //dc:identifier[//oaf:datasourceprefix[.='od______3636'] and matches(., '[0-9]{4}-[0-9]{3}[0-9X]')], //dc:source[//oaf:datasourceprefix[.=('od______2097', 'issn22953671')] and matches(., '^\d{4}-\d{3}[\dX]$')][1]";
//$varISSN = xpath:"(//*[local-name()='setSpec'][starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:') or starts-with(., 'ISSN ')]/normalize-space(replace(., 'ISSN[:\s](.*)$', '$1')), //dc:relation[starts-with(lower-case(.), 'issn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/issn/')]/replace(normalize-space(substring-after(lower-case(.), 'issn')),'[/:]([0-9]{4})-?([0-9X]{4})','$1-$2'), //dc:identifier[matches(., '[0-9]{4}-[0-9]{3}[0-9X]')], //dc:source[//oaf:datasourceprefix[.=('od______2097', 'issn22953671')] and matches(., '^\d{4}-\d{3}[\dX]$')][1], //*[local-name()='isPartOf'][starts-with(., 'urn:ISSN:')]/substring-after(., 'urn:ISSN:'), //dc:identifier[starts-with(., 'urn:issn:')]/substring-after(. ,'urn:issn:'))[1]";
$varISSN = xpath:"(//*[local-name()='setSpec'][starts-with(., 'ISSN')]/substring-after(., 'ISSN'), //dc:source[starts-with(., 'ISSN:') or starts-with(., 'ISSN ')]/normalize-space(replace(., 'ISSN[:\s](.*)$', '$1')), //dc:relation[(starts-with(lower-case(.), 'issn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/issn/')) and matches(., '\d{4}[-\s]?\d{3}[\dX]')]/replace(.,'(issn[/:]|info:eu-repo/semantics/altIdentifier/issn/)([0-9]{4})-?([0-9X]{4})','$2-$3','i'), //dc:identifier[matches(normalize-space(.), '^[0-9]{4}-[0-9]{3}[0-9X](\s*\(print\))?$', 'i')]/replace(., '.*([0-9]{4}-[0-9]{3}[0-9X]).*', '$1'), //dc:source[//oaf:datasourceprefix[.=('od______2097', 'issn22953671')] and matches(., '^\d{4}-\d{3}[\dX]$')][1], //*[local-name()='isPartOf'][starts-with(., 'urn:ISSN:')]/substring-after(., 'urn:ISSN:'), //dc:identifier[starts-with(lower-case(.), 'urn:issn:') or starts-with(lower-case(.), 'issn:')]/substring-after(lower-case(.) ,'issn:'))[1]";
$varEISSN = xpath:"//dc:relation[starts-with(., 'eissn:') or starts-with(., 'info:eu-repo/semantics/altIdentifier/eissn/')]/replace(normalize-space(substring-after(., 'eissn')),'[/:]([0-9]{4})-?([0-9X]{4})','$1-$2'), //dc:identifier[matches(normalize-space(.), '[0-9]{4}-[0-9]{3}[0-9X]\s*\(online\)', 'i')]/replace(., '.*([0-9]{4}-[0-9]{3}[0-9X]).*', '$1')";
//oaf:journal = set($varJournalTitle, @issn = xpath:"$varISSN";);
//to be improved: many identical checks
//$varVol = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/replace(., '^.*?\.\s*(\d{4})($|,.*$)', '$1')";
$varVol = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/replace(., '^.*?\.\s*(\d{4})($|,.*$)', '$1'), //dc:source[starts-with(//*[local-name()='isPartOf'], 'urn:ISSN:')][contains(., ', vol. ')]/normalize-space(substring-before(substring-after(., ', vol. '), ','))";
$varIss = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/normalize-space(substring-before(substring-after(., 'Nr.'), ','))";
//$varSp = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/normalize-space(tokenize(substring-after(., ', p.'), '-')[1])";
$varSp = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/normalize-space(tokenize(substring-after(., ', p.'), '-')[1]), //dc:source[starts-with(//*[local-name()='isPartOf'], 'urn:ISSN:')][contains(., ', pp. ')]/replace(., '^.*, pp. (\d*)-\d*[\s,\.;].*$', '$1')";
//$varEp = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/normalize-space(reverse(tokenize(substring-after(., ', p.'), '-'))[1])";
$varEp = xpath:"//dc:source[//oaf:datasourceprefix[.='od______2712'] and //dc:source[starts-with(., 'ISSN ')] and not(starts-with(., 'ISSN '))]/normalize-space(reverse(tokenize(substring-after(., ', p.'), '-'))[1]), //dc:source[starts-with(//*[local-name()='isPartOf'], 'urn:ISSN:')][contains(., ', pp. ')]/replace(., '^.*, pp. \d*-(\d*)[\s,\.;].*$', '$1')";
//to be improved: many empty attributes
oaf:journal = set($varJournalTitle, @issn = xpath:"$varISSN";, @eissn = xpath:"$varEISSN";, @vol = xpath:"$varVol";, @iss = xpath:"$varIss";, @sp = xpath:"$varSp";, @ep = xpath:"$varEp";);
if xpath:"//oaf:datasourceprefix[.='dovemedicalp']" oaf:fulltext = xpath:"concat('file:///mnt/downloaded_dumps/dovepress/', substring-after(//*[local-name()='header']/*[local-name()='identifier'], 'oai:dovepress.com/'), '.pdf')"; else $varDummy= "''";
if xpath:"//oaf:datasourceprefix[.='od______3848'] and //dc:format[.='application/pdf']" oaf:fulltext = xpath:"//dc:identifier[ends-with(lower-case(normalize-space(.)), '.pdf')][starts-with(lower-case(normalize-space(.)), 'https://cris.cumulus.vub.ac.be/')]"; else $varDummy= "''";
if xpath:"//oaf:datasourceprefix[.='doaj21976775' or .='issn21976775'] and //dc:identifier[starts-with(normalize-space(.), 'https://policyreview.info/node/')]" oaf:fulltext = xpath:"concat(//dc:identifier[starts-with(normalize-space(.), 'https://policyreview.info/node/')]/normalize-space(.), '/pdf')"; else $varDummy= "''";
apply xpath:"//dc:relation[starts-with(., 'https://etalpykla.lituanistikadb.lt/fedora/get/')][//oaf:datasourceprefix[.='od______2712']]" if xpath:"true()" oaf:fulltext = xpath:"normalize-space(.)"; else $varDummy = "''";
if xpath:"//oaf:datasourceprefix[.='od______4149'] and //dc:format[.='application/pdf']" oaf:fulltext = xpath:"//dc:identifier[contains(lower-case(normalize-space(.)), '/datastream/')]"; else $varDummy= "''";
oaf:fulltext = xpath:"//dc:identifier[//oaf:datasourceprefix = 'od______2584' and starts-with(., 'http://fulir.irb.hr/') and ends-with(., '.pdf')]";
// community
// concept should not appear with empty attribute id, i.e when there is no community - ugly, but seems to work (oaf:datasourceprefix = just any field available in all records)
//$varCommunity = xpath:"//*[local-name()='relation'][starts-with(., 'url:https://openaire.eu/communities/')]/substring-after(., 'url:https://openaire.eu/communities/')";
//oaf:concept = set(xpath:"//oaf:datasourceprefix[string-length($varCommunity) gt 0]/''", @id = $varCommunity;);
$varCommunityAtt = xpath:"//*[local-name()='relation'][starts-with(., 'url:https://openaire.eu/communities/') or starts-with(., 'url:https://zenodo.org/communities/')]/substring-after(., 'url:')";
$varCommunityVal = xpath:"//*[local-name()='relation'][starts-with(., 'url:https://openaire.eu/communities/') or starts-with(., 'url:https://zenodo.org/communities/')]/substring-before(., 'url:')";
oaf:concept = set(xpath:"$varCommunityVal", @id = xpath:"subsequence($varCommunityAtt,position(),1)";);
end

View File

@ -0,0 +1,432 @@
<!-- 20210224 , title: xslt_cleaning_datarepo_datacite , copy from production -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oaf="http://namespace.openaire.eu/oaf"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:datacite="http://datacite.org/schema/kernel-3"
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
xmlns:vocabulary="http://eu/dnetlib/transform/clean"
xmlns:dateCleaner="http://eu/dnetlib/transform/dateISO"
exclude-result-prefixes="xsl vocabulary dateCleaner"
version="2.0">
<xsl:param name="varOfficialName" />
<xsl:param name="varDsType" />
<xsl:param name="varDataSourceId" />
<xsl:param name="varFP7" select="'corda_______::'" />
<xsl:param name="varH2020" select="'corda__h2020::'" />
<xsl:param name="varAKA" select="'aka_________::'" />
<xsl:param name="varARC" select="'arc_________::'" />
<xsl:param name="varCONICYT" select="'conicytf____::'" />
<xsl:param name="varDFG" select="'dfgf________::'" />
<xsl:param name="varFCT" select="'fct_________::'" />
<xsl:param name="varFWF" select="'fwf_________::'" />
<xsl:param name="varHRZZ" select="'irb_hr______::'" /> <!-- HRZZ not found -->
<xsl:param name="varMESTD" select="'mestd_______::'" />
<xsl:param name="varMZOS" select="'irb_hr______::'" />
<xsl:param name="varNHMRC" select="'nhmrc_______::'" />
<xsl:param name="varNIH" select="'nih_________::'" />
<xsl:param name="varNSF" select="'nsf_________::'" />
<xsl:param name="varNWO" select="'nwo_________::'" />
<xsl:param name="varRCUK" select="'rcuk________::'" />
<xsl:param name="varSFI" select="'sfi_________::'" />
<xsl:param name="varSGOV" select="'sgov________::'" /> <!-- SGOV to be added, awaiting DOI from Pilar, found project ids not in CSV list? -->
<xsl:param name="varSNSF" select="'snsf________::'" />
<xsl:param name="varTARA" select="'taraexp_____::'" /> <!-- TARA to be added, awaiting DOI from André -->
<xsl:param name="varTUBITAK" select="'tubitakf____::'" />
<xsl:param name="varWT" select="'wt__________::'" />
<xsl:param name="index" select="0" />
<xsl:param name="transDate" select="current-dateTime()" />
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)" />
<xsl:template match="/">
<xsl:call-template name="validRecord" />
</xsl:template>
<xsl:template name="terminate">
<xsl:message terminate="yes">
record is not compliant, transformation is interrupted.
</xsl:message>
</xsl:template>
<xsl:template name="validRecord">
<record>
<xsl:apply-templates select="//*[local-name() = 'header']" />
<metadata>
<xsl:apply-templates select="//*[local-name() = 'metadata']//*[local-name() = 'resource']" /> <!-- for CoCoON many deleted records appeared among the transformed records -->
<xsl:if test="//oai:header/@status='deleted'">
<xsl:call-template name="terminate" />
</xsl:if>
<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle'][not(. = '123456789') and not(starts-with(., 'textgrid:'))]">
<oaf:identifier>
<xsl:attribute name="identifierType">
<xsl:value-of select="'handle'" />
</xsl:attribute>
<xsl:if test="contains(., '://hdl.handle.net/')">
<xsl:value-of select="substring-after(., '://hdl.handle.net/')" />
</xsl:if>
<xsl:if test="not(contains(., '://hdl.handle.net/'))">
<xsl:value-of select="." />
</xsl:if>
</oaf:identifier>
</xsl:for-each>
<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
<oaf:identifier>
<xsl:attribute name="identifierType">
<xsl:value-of select="'doi'" />
</xsl:attribute> <!--
<xsl:value-of select="."/>
-->
<xsl:if test="contains(., '://dx.doi.org/')">
<xsl:value-of select="substring-after(., '://dx.doi.org/')" />
</xsl:if>
<xsl:if test="not(contains(., '://dx.doi.org/'))">
<xsl:value-of select="." />
</xsl:if>
</oaf:identifier>
</xsl:for-each>
<xsl:if test="//*[local-name()='date']/@dateType='Available' and //*[local-name()='datasourceprefix']!='r33ffb097cef'">
<xsl:variable name="varEmbargoEndDate" select="dateCleaner:dateISO( normalize-space(//*[local-name()='date'][@dateType='Available']))" />
<xsl:choose>
<xsl:when test="string-length($varEmbargoEndDate) &gt; 0">
<oaf:embargoenddate>
<xsl:value-of select="$varEmbargoEndDate" />
</oaf:embargoenddate>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="terminate" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:variable name="varTypLst" select="distinct-values((//*[local-name()='resourceType']/(., @resourceTypeGeneral)))" />
<xsl:variable name="varCobjCatLst" select="distinct-values((for $i in $varTypLst return vocabulary:clean( normalize-space($i), 'dnet:publication_resource')))" />
<xsl:variable name="varCobjSupLst" select="for $i in $varCobjCatLst return concat($i, '###', vocabulary:clean( normalize-space($i), 'dnet:result_typologies'))" />
<dr:CobjCategory>
<xsl:choose>
<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other')]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other')][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0000'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0000'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type" select="'other'" />
<xsl:value-of select="'0000'" />
</xsl:otherwise>
</xsl:choose>
</dr:CobjCategory> <!-- review status --> <!-- no review hints found in resource type declarations, no version declarations found -->
<xsl:variable name="varRefereedConvt" select="for $i in ( //*[local-name()='resourceType']/(., @resourceTypeGeneral), //oai:setSpec, //*[local-name()='description']) return vocabulary:clean( normalize-space($i), 'dnet:review_levels')" />
<xsl:variable name="varRefereedIdntf" select="( //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])pre[\.\-_\\/\s\(\)%\d#:]?prints?([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0002', //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])refereed([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0001', //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '.*-peer-reviewed-(fulltext-)?article-.*')]/'0001')" />
<xsl:variable name="varRefereedVersn" select="(//*[local-name()='version'][matches(lower-case(.), '.*peer[\s\-\.\\_/:%]?reviewed.*')]/'0001', //*[local-name()='version'][matches(normalize-space(lower-case(.)), '^(v|vs|version|rel|release)?[\s\.\-_]*0$')]/'0002', //*[local-name()='version'][matches(lower-case(.), '(^|[\s\-\.\\_/:%].*)(beta|draft|trial|test)([\s\-\.\\_/:%].*|$)')]/'0002', //*[local-name()='version'][matches(lower-case(.), '.*submi(tted|ssion|ttal).*')]/'0002') " />
<xsl:variable name="varRefereedOther" select="(//*[local-name()='publisher'][matches(lower-case(.), '.*[\s\-\.\\_/:%]pre[\s\-\.\\_/:%]?prints?([\s\-\.\\_/:%].*|$)')]/'0002', //*[local-name()='description'][matches(lower-case(.), '^peer[\s\-\.\\_/:%]?reviewed$')]/'0001', //*[local-name()='description'][matches(lower-case(.), '^pre[\s\-\.\\_/:%]?prints?$')]/'0002') " />
<xsl:variable name="varRefereedReltn" select="//*[local-name() = 'relatedIdentifier'][./@relationType/lower-case(.)='isreviewedby']/'0001'" />
<xsl:variable name="varRefereedDesct" select="(//*[local-name() = 'description'] [matches(lower-case(.), '.*(this\s*book|this\s*volume|it)\s*constitutes\s*the\s*(thoroughly\s*)?refereed') or matches(lower-case(.), '.*peer[\.\-_/\s\(\)]?review\s*under\s*responsibility\s*of.*') or matches(lower-case(.), '(this|a)\s*(article|preprint)\s*(has\s*been\s*)?(peer[\-\s]*)?reviewed\s*and\s*recommended\s*by\s*peer[\-\s]*community')]/'0001')" />
<xsl:variable name="varRefereed" select="($varRefereedConvt, $varRefereedIdntf, $varRefereedReltn, $varRefereedVersn, $varRefereedOther, $varRefereedReltn, $varRefereedDesct)" />
<xsl:choose>
<xsl:when test="count($varRefereed[. = '0001']) &gt; 0">
<oaf:refereed>
<xsl:value-of select="'0001'" />
</oaf:refereed>
</xsl:when>
<xsl:when test="count($varRefereed[. = '0002']) &gt; 0">
<oaf:refereed>
<xsl:value-of select="'0002'" />
</oaf:refereed>
</xsl:when>
</xsl:choose>
<oaf:dateAccepted>
<xsl:variable name="theDate">
<xsl:choose>
<xsl:when test="string-length(normalize-space(//*[local-name()='date'][@dateType='Issued'])) &gt; 3">
<xsl:value-of select="//*[local-name()='date'][@dateType='Issued']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="//*[local-name()='publicationYear']" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="dateCleaner:dateISO( normalize-space($theDate) )" />
</oaf:dateAccepted>
<xsl:choose>
<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
<oaf:accessrights>
<xsl:value-of select="vocabulary:clean( //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'dnet:access_modes')" />
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'Creative Commons') or starts-with(normalize-space(.),'CC BY 4.0') or starts-with(normalize-space(.), 'GNU LESSER GENERAL PUBLIC LICENSE')]">
<oaf:accessrights>
<xsl:text>OPEN</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'http://opendatacommons.org')]">
<oaf:accessrights>
<xsl:text>OPEN</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'Open access data at least for academic use')]">
<oaf:accessrights>
<xsl:text>RESTRICTED</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<oaf:accessrights>
<xsl:text>UNKNOWN</xsl:text>
</oaf:accessrights>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="//*[local-name()='rights']/@rightsURI[starts-with(normalize-space(.), 'http') and matches(., '.*(/licenses|/publicdomain|unlicense.org/|/legal-and-data-protection-notices|/download/license|/open-government-licence).*')]">
<oaf:license>
<xsl:value-of select="." />
</oaf:license>
</xsl:for-each>
<oaf:language>
<xsl:value-of select="vocabulary:clean( //*[local-name()='language'], 'dnet:languages')" />
</oaf:language> <!-- country DE for items from TextGrid -->
<xsl:if test="$varDataSourceId = 're3data_____::r3d100011365'">
<oaf:country>DE</oaf:country>
</xsl:if>
<xsl:for-each select="//*[local-name()='nameIdentifier']">
<xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))" />
</oaf:projectid>
</xsl:if>
<xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))" />
</oaf:projectid>
</xsl:if>
</xsl:for-each>
<oaf:hostedBy>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId" />
</xsl:attribute>
</oaf:hostedBy>
<oaf:collectedFrom>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId" />
</xsl:attribute>
</oaf:collectedFrom>
</metadata>
<xsl:copy-of select="//*[local-name() = 'about']" />
</record>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers']">
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
<xsl:copy-of select="./*" />
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://hdl.handle.net/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://nbn-resolving.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute> <!--
<xsl:value-of
select="concat('http://dx.doi.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
-->
<xsl:value-of select="//*[local-name() = 'resource']/(*[local-name()='identifier'][not(contains(., '://dx.doi.org/'))]/concat('http://dx.doi.org/', .), *[local-name()='identifier'][contains(., '://dx.doi.org/')])" />
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
<!-- cut off DOI resolver prefix to just get the number part -->
<xsl:if test=".[@identifierType='DOI'][contains(., '://dx.doi.org/')]">
<xsl:element name="identifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="identifierType">
<xsl:value-of select="'DOI'" />
</xsl:attribute>
<xsl:value-of select="substring-after(., '://dx.doi.org/')" />
</xsl:element>
</xsl:if>
<xsl:copy-of select=".[not(contains(., '://dx.doi.org/'))]" /> <!--
<xsl:copy-of select="."/>
-->
<xsl:if test="not(//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers'])">
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
<xsl:if test=".[@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://hdl.handle.net/', .)" />
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://nbn-resolving.org/', .)" />
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://dx.doi.org/', .)" />
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:if> <!-- funding -->
<xsl:for-each select="//*[local-name()='fundingReference']">
<!-- FP7 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004963', '10.13039/100011199') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- H2020 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100010661') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- AKA -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002341') or contains(./*[local-name()='funderName'], 'Suomen Akatemia') or contains(./*[local-name()='funderName'], 'Academy of Finland')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- ARC -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000923') or contains(./*[local-name()='funderName'], 'Australian Research Council')) and matches(./*[local-name()='awardNumber'], '^\d{6}$')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, replace(./*[local-name()='awardNumber'], '.*(^\d{6}$).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- CONICYT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002848') or contains(./*[local-name()='funderName'], 'Comisión Nacional de Investigación Científica y Tecnológica') or contains(./*[local-name()='funderName'], 'CONICYT')">
<oaf:projectid>
<xsl:value-of select="concat($varCONICYT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- DFG -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001659') or contains(./*[local-name()='funderName'], 'Deutsche Forschungsgemeinschaft') or contains(./*[local-name()='funderName'], 'DFG')">
<oaf:projectid>
<xsl:value-of select="concat($varDFG, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- FCT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or contains(./*[local-name()='funderName'], 'Fundação para a Ciência e a Tecnologia')">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- FWF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002428') or contains(./*[local-name()='funderName'], 'Fonds zur Förderung der Wissenschaftlichen Forschung') or contains(./*[local-name()='funderName'], 'Austrian Science Fund')">
<oaf:projectid>
<xsl:value-of select="concat($varFWF, ./*[local-name() = 'awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- MESTD -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or (contains(./*[local-name()='funderName'], 'Ministarstvo Prosvete, Nauke i Tehnolo') and contains(./*[local-name()='funderName'], 'kog Razvoja')) or contains(./*[local-name()='funderName'], 'MESTD')">
<oaf:projectid>
<xsl:value-of select="concat($varMESTD, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- MZOS -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100006588') or contains(./*[local-name()='funderName'], 'Ministarstvo Znanosti, Obrazovanja i Sporta') or contains(./*[local-name()='funderName'], 'Ministry of Science, Education and Sports')">
<oaf:projectid>
<xsl:value-of select="concat($varMZOS, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NHMRC -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000925') or contains(./*[local-name()='funderName'], 'National Health and Medical Research Council') or contains(./*[local-name()='funderName'], 'NHMRC')">
<oaf:projectid>
<xsl:value-of select="concat($varNHMRC, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NIH -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100000002') or contains(./*[local-name()='funderName'], 'National Institutes of Health')">
<oaf:projectid>
<xsl:value-of select="concat($varNIH, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org') = ('10.13039/100000001') or contains(./*[local-name()='funderName'], 'National Science Foundation')">
<oaf:projectid>
<xsl:value-of select="concat($varNSF, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NWO -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100003246') or contains(./*[local-name()='funderName'], 'Netherlands Organisation for Scientific Research') or contains(./*[local-name()='funderName'], 'Nederlandse Organisatie voor Wetenschappelijk Onderzoek')">
<oaf:projectid>
<xsl:value-of select="concat($varNWO, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- RCUK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000690') or contains(./*[local-name()='funderName'], 'Research Councils UK') or contains(./*[local-name()='funderName'], 'RCUK')">
<oaf:projectid>
<xsl:value-of select="concat($varRCUK, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- SFI -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001602') or contains(./*[local-name()='funderName'], 'Science Foundation Ireland')) and matches(./*[local-name()='awardNumber'], '.*([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+.*')">
<oaf:projectid>
<xsl:value-of select="concat($varSFI, replace(./*[local-name()='awardNumber'], '.*(^|\s)(([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+)($|\s).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- SNSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001711') or contains(./*[local-name()='funderName'], 'Swiss National Science Foundation') or contains(./*[local-name()='funderName'], 'Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung')">
<oaf:projectid>
<xsl:value-of select="concat($varSNSF, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- TUBITAK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004410') or contains(./*[local-name()='funderName'], 'Turkish National Science and Research Council') or (contains(./*[local-name()='funderName'], 'Türkiye Bilimsel ve Teknolojik Ara') and contains(./*[local-name()='funderName'], 'rma Kurumu'))">
<oaf:projectid>
<xsl:value-of select="concat($varTUBITAK, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- WT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100004440') or contains(./*[local-name()='funderName'], 'Wellcome Trust')">
<oaf:projectid>
<xsl:value-of select="concat($varWT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name() = 'relatedIdentifier' and @relatedIdentifierType = 'Handle']">
<datacite:relatedIdentifier relatedIdentifierType="OPENAIRE" relationType="{./@relationType}">
<xsl:value-of select="concat($datasourcePrefix, '::', ./text())" />
</datacite:relatedIdentifier>
</xsl:template>
<xsl:template match="//*[local-name() = 'header']">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
<xsl:element name="dr:dateOfTransformation">
<xsl:value-of select="$transDate" />
</xsl:element>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,472 @@
<!-- 20210224 , title: xslt_cleaning_datarepo_datacite , copy from production -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:oai="http://www.openarchives.org/OAI/2.0/" xmlns:datacite="http://datacite.org/schema/kernel-3" xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy" xmlns:dr="http://www.driver-repository.eu/namespace/dr" exclude-result-prefixes="TransformationFunction" extension-element-prefixes="TransformationFunction" version="2.0">
<xsl:param name="varOfficialName" />
<xsl:param name="varDsType" />
<xsl:param name="varDataSourceId" />
<xsl:param name="varFP7" select="'corda_______::'" />
<xsl:param name="varH2020" select="'corda__h2020::'" />
<xsl:param name="varAKA" select="'aka_________::'" />
<xsl:param name="varARC" select="'arc_________::'" />
<xsl:param name="varCONICYT" select="'conicytf____::'" />
<xsl:param name="varDFG" select="'dfgf________::'" />
<xsl:param name="varFCT" select="'fct_________::'" />
<xsl:param name="varFWF" select="'fwf_________::'" />
<xsl:param name="varHRZZ" select="'irb_hr______::'" /> <!-- HRZZ not found -->
<xsl:param name="varMESTD" select="'mestd_______::'" />
<xsl:param name="varMZOS" select="'irb_hr______::'" />
<xsl:param name="varNHMRC" select="'nhmrc_______::'" />
<xsl:param name="varNIH" select="'nih_________::'" />
<xsl:param name="varNSF" select="'nsf_________::'" />
<xsl:param name="varNWO" select="'nwo_________::'" />
<xsl:param name="varRCUK" select="'rcuk________::'" />
<xsl:param name="varSFI" select="'sfi_________::'" />
<xsl:param name="varSGOV" select="'sgov________::'" /> <!-- SGOV to be added, awaiting DOI from Pilar, found project ids not in CSV list? -->
<xsl:param name="varSNSF" select="'snsf________::'" />
<xsl:param name="varTARA" select="'taraexp_____::'" /> <!-- TARA to be added, awaiting DOI from André -->
<xsl:param name="varTUBITAK" select="'tubitakf____::'" />
<xsl:param name="varWT" select="'wt__________::'" />
<xsl:param name="index" select="0" />
<xsl:param name="transDate" select="current-dateTime()" />
<xsl:variable name="tf" select="TransformationFunction:getInstance()" />
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)" />
<xsl:template match="/">
<xsl:call-template name="validRecord" />
</xsl:template>
<xsl:template name="terminate">
<xsl:message terminate="yes">
record is not compliant, transformation is interrupted.
</xsl:message>
</xsl:template>
<xsl:template name="validRecord">
<record>
<xsl:apply-templates select="//*[local-name() = 'header']" />
<metadata>
<xsl:apply-templates select="//*[local-name() = 'metadata']//*[local-name() = 'resource']" /> <!-- for CoCoON many deleted records appeared among the transformed records -->
<xsl:if test="//oai:header/@status='deleted'">
<xsl:call-template name="terminate" />
</xsl:if>
<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle'][not(. = '123456789') and not(starts-with(., 'textgrid:'))]">
<oaf:identifier>
<xsl:attribute name="identifierType">
<xsl:value-of select="'handle'" />
</xsl:attribute>
<xsl:if test="contains(., '://hdl.handle.net/')">
<xsl:value-of select="substring-after(., '://hdl.handle.net/')" />
</xsl:if>
<xsl:if test="not(contains(., '://hdl.handle.net/'))">
<xsl:value-of select="." />
</xsl:if>
</oaf:identifier>
</xsl:for-each>
<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
<oaf:identifier>
<xsl:attribute name="identifierType">
<xsl:value-of select="'doi'" />
</xsl:attribute> <!--
<xsl:value-of select="."/>
-->
<xsl:if test="contains(., '://dx.doi.org/')">
<xsl:value-of select="substring-after(., '://dx.doi.org/')" />
</xsl:if>
<xsl:if test="not(contains(., '://dx.doi.org/'))">
<xsl:value-of select="." />
</xsl:if>
</oaf:identifier>
</xsl:for-each>
<xsl:if test="//*[local-name()='date']/@dateType='Available' and //*[local-name()='datasourceprefix']!='r33ffb097cef'">
<xsl:variable name="varEmbargoEndDate" select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='date'][@dateType='Available']), 'DateISO8601')" />
<xsl:choose>
<xsl:when test="string-length($varEmbargoEndDate) &gt; 0">
<oaf:embargoenddate>
<xsl:value-of select="$varEmbargoEndDate" />
</oaf:embargoenddate>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="terminate" />
</xsl:otherwise>
</xsl:choose>
</xsl:if> <!--
<xsl:choose>
or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='software' or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='software' or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='Film' or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='Sound' or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='PhysicalObject' or //*[local-name()='resourceType']/@resourceTypeGeneral/lower-case()='Audiovisual'">
<xsl:when test="lower-case(//*[local-name()='resourceType']/@resourceTypeGeneral)=('dataset', 'software', 'collection', 'film', 'sound', 'physicalobject', 'audiovisual')">
<xsl:when test="lower-case(//*[local-name()='resourceType']/@resourceTypeGeneral)=('dataset', 'software', 'collection', 'film', 'sound', 'physicalobject', 'audiovisual', 'model', 'workflow', 'service', 'image') or //*[local-name()='resourceType'][lower-case(@resourceTypeGeneral)='other' and lower-case(.)=('study', 'research data', 'image', 'photos et images')] or //*[local-name()='resourceType'][lower-case(.)='article'] or (//*[local-name()='resourceType'][lower-case(./@resourceTypeGeneral)='other' and lower-case(.)=('study', 'egi virtual appliance')])">
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="terminate"/>
</xsl:otherwise>
</xsl:choose>
-->
<!--
<dr:CobjCategory>
<xsl:value-of
select="TransformationFunction:convertString($tf, distinct-values(//*[local-name()='resourceType']/@resourceTypeGeneral), 'TextTypologies')" />
</dr:CobjCategory>
<dr:CobjCategory>
<xsl:variable name='varCobjCategory' select="TransformationFunction:convertString($tf, distinct-values(//*[local-name()='resourceType']/@resourceTypeGeneral), 'TextTypologies')" />
<xsl:attribute name="type" select="TransformationFunction:convertString($tf, $varCobjCategory, 'SuperTypes')"/>
<xsl:value-of select="$varCobjCategory" />
</dr:CobjCategory>
-->
<xsl:variable name="varTypLst" select="distinct-values((//*[local-name()='resourceType']/(., @resourceTypeGeneral)))" />
<xsl:variable name="varCobjCatLst" select="distinct-values((for $i in $varTypLst return TransformationFunction:convertString($tf, normalize-space($i), 'TextTypologies')))" />
<xsl:variable name="varCobjSupLst" select="for $i in $varCobjCatLst return concat($i, '###', TransformationFunction:convertString($tf, normalize-space($i), 'SuperTypes'))" />
<dr:CobjCategory>
<xsl:choose>
<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other')]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other')][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0000'))]) &gt; 0">
<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0000'))][1]" />
<xsl:attribute name="type" select="substring-after($varCobjSup, '###')" />
<xsl:value-of select="substring-before($varCobjSup, '###')" />
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type" select="'other'" />
<xsl:value-of select="'0000'" />
</xsl:otherwise>
</xsl:choose>
</dr:CobjCategory> <!-- review status --> <!-- no review hints found in resource type declarations, no version declarations found -->
<xsl:variable name="varRefereedConvt" select="for $i in ( //*[local-name()='resourceType']/(., @resourceTypeGeneral), //oai:setSpec, //*[local-name()='description']) return TransformationFunction:convertString($tf, normalize-space($i), 'ReviewLevels')" /> <!--
//<xsl:variable name="varRefereedIdntf" select="//*[local-name()=('identifier', 'alternateIdentifier')][matches(lower-case(.), '.*[\s\-\.\\_/:]preprints?[\s\-\.\\_/:].*')]/'0002' "/>
-->
<xsl:variable name="varRefereedIdntf" select="( //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])pre[\.\-_\\/\s\(\)%\d#:]?prints?([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0002', //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])refereed([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0001', //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '.*-peer-reviewed-(fulltext-)?article-.*')]/'0001')" />
<xsl:variable name="varRefereedVersn" select="(//*[local-name()='version'][matches(lower-case(.), '.*peer[\s\-\.\\_/:%]?reviewed.*')]/'0001', //*[local-name()='version'][matches(normalize-space(lower-case(.)), '^(v|vs|version|rel|release)?[\s\.\-_]*0$')]/'0002', //*[local-name()='version'][matches(lower-case(.), '(^|[\s\-\.\\_/:%].*)(beta|draft|trial|test)([\s\-\.\\_/:%].*|$)')]/'0002', //*[local-name()='version'][matches(lower-case(.), '.*submi(tted|ssion|ttal).*')]/'0002') " />
<xsl:variable name="varRefereedOther" select="(//*[local-name()='publisher'][matches(lower-case(.), '.*[\s\-\.\\_/:%]pre[\s\-\.\\_/:%]?prints?([\s\-\.\\_/:%].*|$)')]/'0002', //*[local-name()='description'][matches(lower-case(.), '^peer[\s\-\.\\_/:%]?reviewed$')]/'0001', //*[local-name()='description'][matches(lower-case(.), '^pre[\s\-\.\\_/:%]?prints?$')]/'0002') " />
<xsl:variable name="varRefereedReltn" select="//*[local-name() = 'relatedIdentifier'][./@relationType/lower-case(.)='isreviewedby']/'0001'" />
<xsl:variable name="varRefereedDesct" select="(//*[local-name() = 'description'] [matches(lower-case(.), '.*(this\s*book|this\s*volume|it)\s*constitutes\s*the\s*(thoroughly\s*)?refereed') or matches(lower-case(.), '.*peer[\.\-_/\s\(\)]?review\s*under\s*responsibility\s*of.*') or matches(lower-case(.), '(this|a)\s*(article|preprint)\s*(has\s*been\s*)?(peer[\-\s]*)?reviewed\s*and\s*recommended\s*by\s*peer[\-\s]*community')]/'0001')" />
<xsl:variable name="varRefereed" select="($varRefereedConvt, $varRefereedIdntf, $varRefereedReltn, $varRefereedVersn, $varRefereedOther, $varRefereedReltn, $varRefereedDesct)" />
<xsl:choose>
<xsl:when test="count($varRefereed[. = '0001']) &gt; 0">
<oaf:refereed>
<xsl:value-of select="'0001'" />
</oaf:refereed>
</xsl:when>
<xsl:when test="count($varRefereed[. = '0002']) &gt; 0">
<oaf:refereed>
<xsl:value-of select="'0002'" />
</oaf:refereed>
</xsl:when>
</xsl:choose>
<oaf:dateAccepted>
<xsl:variable name="theDate">
<xsl:choose>
<xsl:when test="string-length(normalize-space(//*[local-name()='date'][@dateType='Issued'])) &gt; 3">
<xsl:value-of select="//*[local-name()='date'][@dateType='Issued']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="//*[local-name()='publicationYear']" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="TransformationFunction:convertString($tf, normalize-space($theDate), 'DateISO8601')" />
</oaf:dateAccepted>
<xsl:choose>
<!--
<xsl:if test="//*[local-name() = 'datasourceprefix'][.='r310e4cd113d'] and not(boolean(//*[local-name() = 'rights']/@rightsURI ) )]">
<oaf:skip>
<xsl:value-of select="TransformationFunction:skipRecord($tf, $index)"/>
</oaf:skip>
</xsl:if>
-->
<!-- <xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
<oaf:accessrights>
<xsl:value-of select="TransformationFunction:convertString($tf, //*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')"/>
</oaf:accessrights>
</xsl:when>
-->
<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
<oaf:accessrights>
<xsl:value-of select="TransformationFunction:convertString($tf, //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')" />
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'Creative Commons') or starts-with(normalize-space(.),'CC BY 4.0') or starts-with(normalize-space(.), 'GNU LESSER GENERAL PUBLIC LICENSE')]">
<oaf:accessrights>
<xsl:text>OPEN</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'http://opendatacommons.org')]">
<oaf:accessrights>
<xsl:text>OPEN</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'Open access data at least for academic use')]">
<oaf:accessrights>
<xsl:text>RESTRICTED</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<oaf:accessrights>
<xsl:text>UNKNOWN</xsl:text>
</oaf:accessrights>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="//*[local-name()='rights']/@rightsURI[starts-with(normalize-space(.), 'http') and matches(., '.*(/licenses|/publicdomain|unlicense.org/|/legal-and-data-protection-notices|/download/license|/open-government-licence).*')]">
<oaf:license>
<xsl:value-of select="." />
</oaf:license>
</xsl:for-each>
<oaf:language>
<xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')" />
</oaf:language> <!-- country DE for items from TextGrid -->
<xsl:if test="$varDataSourceId = 're3data_____::r3d100011365'">
<oaf:country>DE</oaf:country>
</xsl:if> <!--
<xsl:if test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics/embargoedAccess')]">
<oaf:embargoenddate>
<xsl:value-of select="//*[local-name()='date']/@dateType='Available'"/>
</oaf:embargoenddate>
</xsl:if>
-->
<!--
<xsl:if test="not(//*[local-name()='nameIdentifier'][starts-with(., 'info:eu-repo/grant')])">
<xsl:call-template name="terminate"/>
</xsl:if>
-->
<xsl:for-each select="//*[local-name()='nameIdentifier']">
<xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))" />
</oaf:projectid>
</xsl:if>
<xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))" />
</oaf:projectid>
</xsl:if>
</xsl:for-each>
<oaf:hostedBy>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId" />
</xsl:attribute>
</oaf:hostedBy>
<oaf:collectedFrom>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId" />
</xsl:attribute>
</oaf:collectedFrom>
</metadata>
<xsl:copy-of select="//*[local-name() = 'about']" />
</record>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers']">
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
<xsl:copy-of select="./*" />
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://hdl.handle.net/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://nbn-resolving.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute> <!--
<xsl:value-of
select="concat('http://dx.doi.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
-->
<xsl:value-of select="//*[local-name() = 'resource']/(*[local-name()='identifier'][not(contains(., '://dx.doi.org/'))]/concat('http://dx.doi.org/', .), *[local-name()='identifier'][contains(., '://dx.doi.org/')])" />
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
<!-- cut off DOI resolver prefix to just get the number part -->
<xsl:if test=".[@identifierType='DOI'][contains(., '://dx.doi.org/')]">
<xsl:element name="identifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="identifierType">
<xsl:value-of select="'DOI'" />
</xsl:attribute>
<xsl:value-of select="substring-after(., '://dx.doi.org/')" />
</xsl:element>
</xsl:if>
<xsl:copy-of select=".[not(contains(., '://dx.doi.org/'))]" /> <!--
<xsl:copy-of select="."/>
-->
<xsl:if test="not(//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers'])">
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
<xsl:if test=".[@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://hdl.handle.net/', .)" />
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://nbn-resolving.org/', .)" />
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'" />
</xsl:attribute>
<xsl:value-of select="concat('http://dx.doi.org/', .)" />
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:if> <!-- funding -->
<xsl:for-each select="//*[local-name()='fundingReference']">
<!-- FP7 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004963', '10.13039/100011199') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- H2020 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100010661') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- AKA -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002341') or contains(./*[local-name()='funderName'], 'Suomen Akatemia') or contains(./*[local-name()='funderName'], 'Academy of Finland')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- ARC -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000923') or contains(./*[local-name()='funderName'], 'Australian Research Council')) and matches(./*[local-name()='awardNumber'], '^\d{6}$')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, replace(./*[local-name()='awardNumber'], '.*(^\d{6}$).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- CONICYT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002848') or contains(./*[local-name()='funderName'], 'Comisión Nacional de Investigación Científica y Tecnológica') or contains(./*[local-name()='funderName'], 'CONICYT')">
<oaf:projectid>
<xsl:value-of select="concat($varCONICYT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- DFG -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001659') or contains(./*[local-name()='funderName'], 'Deutsche Forschungsgemeinschaft') or contains(./*[local-name()='funderName'], 'DFG')">
<oaf:projectid>
<xsl:value-of select="concat($varDFG, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- FCT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or contains(./*[local-name()='funderName'], 'Fundação para a Ciência e a Tecnologia')">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- FWF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002428') or contains(./*[local-name()='funderName'], 'Fonds zur Förderung der Wissenschaftlichen Forschung') or contains(./*[local-name()='funderName'], 'Austrian Science Fund')">
<oaf:projectid>
<xsl:value-of select="concat($varFWF, ./*[local-name() = 'awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- MESTD -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or (contains(./*[local-name()='funderName'], 'Ministarstvo Prosvete, Nauke i Tehnolo') and contains(./*[local-name()='funderName'], 'kog Razvoja')) or contains(./*[local-name()='funderName'], 'MESTD')">
<oaf:projectid>
<xsl:value-of select="concat($varMESTD, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- MZOS -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100006588') or contains(./*[local-name()='funderName'], 'Ministarstvo Znanosti, Obrazovanja i Sporta') or contains(./*[local-name()='funderName'], 'Ministry of Science, Education and Sports')">
<oaf:projectid>
<xsl:value-of select="concat($varMZOS, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NHMRC -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000925') or contains(./*[local-name()='funderName'], 'National Health and Medical Research Council') or contains(./*[local-name()='funderName'], 'NHMRC')">
<oaf:projectid>
<xsl:value-of select="concat($varNHMRC, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NIH -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100000002') or contains(./*[local-name()='funderName'], 'National Institutes of Health')">
<oaf:projectid>
<xsl:value-of select="concat($varNIH, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org') = ('10.13039/100000001') or contains(./*[local-name()='funderName'], 'National Science Foundation')">
<oaf:projectid>
<xsl:value-of select="concat($varNSF, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- NWO -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100003246') or contains(./*[local-name()='funderName'], 'Netherlands Organisation for Scientific Research') or contains(./*[local-name()='funderName'], 'Nederlandse Organisatie voor Wetenschappelijk Onderzoek')">
<oaf:projectid>
<xsl:value-of select="concat($varNWO, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- RCUK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000690') or contains(./*[local-name()='funderName'], 'Research Councils UK') or contains(./*[local-name()='funderName'], 'RCUK')">
<oaf:projectid>
<xsl:value-of select="concat($varRCUK, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- SFI -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001602') or contains(./*[local-name()='funderName'], 'Science Foundation Ireland')) and matches(./*[local-name()='awardNumber'], '.*([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+.*')">
<oaf:projectid>
<xsl:value-of select="concat($varSFI, replace(./*[local-name()='awardNumber'], '.*(^|\s)(([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+)($|\s).*', '$2'))" />
</oaf:projectid>
</xsl:if> <!-- SNSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001711') or contains(./*[local-name()='funderName'], 'Swiss National Science Foundation') or contains(./*[local-name()='funderName'], 'Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung')">
<oaf:projectid>
<xsl:value-of select="concat($varSNSF, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- TUBITAK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004410') or contains(./*[local-name()='funderName'], 'Turkish National Science and Research Council') or (contains(./*[local-name()='funderName'], 'Türkiye Bilimsel ve Teknolojik Ara') and contains(./*[local-name()='funderName'], 'rma Kurumu'))">
<oaf:projectid>
<xsl:value-of select="concat($varTUBITAK, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if> <!-- WT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100004440') or contains(./*[local-name()='funderName'], 'Wellcome Trust')">
<oaf:projectid>
<xsl:value-of select="concat($varWT, ./*[local-name()='awardNumber'])" />
</oaf:projectid>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name() = 'relatedIdentifier' and @relatedIdentifierType = 'Handle']">
<datacite:relatedIdentifier relatedIdentifierType="OPENAIRE" relationType="{./@relationType}">
<xsl:value-of select="concat($datasourcePrefix, '::', ./text())" />
</datacite:relatedIdentifier>
</xsl:template>
<xsl:template match="//*[local-name() = 'header']">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
<xsl:element name="dr:dateOfTransformation">
<xsl:value-of select="$transDate" />
</xsl:element>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,82 @@
<!-- apart of literature v4: xslt_cleaning_oaiOpenaire_datacite_ExchangeLandingpagePid ; transformation script production , 2021-02-18 -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:datacite="http://datacite.org/schema/kernel-4" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaire="http://namespace.openaire.eu/schema/oaire/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:TransformationFunction="http://eu/dnetlib/transform/functionProxy" exclude-result-prefixes="xsl TransformationFunction">
<xsl:param name="varOfficialName" />
<xsl:param name="varDsType" />
<xsl:param name="varDataSourceId" />
<xsl:param name="varFP7" select="'corda_______::'" />
<xsl:param name="varH2020" select="'corda__h2020::'" />
<xsl:template match="/">
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)" />
<xsl:call-template name="validRecord" />
</xsl:template>
<xsl:template name="terminate">
<xsl:message terminate="yes">
record is not compliant, transformation is interrupted.
</xsl:message>
</xsl:template>
<xsl:template name="validRecord">
<record>
<xsl:apply-templates select="//*[local-name() = 'header']" />
<metadata>
<!-- drop oaire resource -->
<!--
<xsl:apply-templates select="//*[local-name() = 'metadata']//*[local-name() = 'resource']"/>
-->
<datacite:resource>
<!-- datacite:identifier -->
<xsl:choose>
<!-- cut off DOI resolver prefix to just get the number part -->
<xsl:when test="(//datacite:identifier, //datacite:alternateIdentifier)[@identifierType='DOI' or @alternateIdentifierType='DOI' or contains(., '://dx.doi.org/10.')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'DOI'" />
<xsl:value-of select="//datacite:identifier[@identifierType='DOI'][contains(., '://dx.doi.org/')]/substring-after(., '://dx.doi.org/'),
(//datacite:identifier, //datacite:alternateIdentifier)[@identifierType='DOI' or @alternateIdentifierType='DOI'][not(contains(., '://dx.doi.org/'))],
//datacite:identifier[contains(., '://dx.doi.org/10.')]/substring-after(., '://dx.doi.org/')" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//datacite:identifier[lower-case(@identifierType)='handle'], //datacite:identifier[contains(., '://refubium.fu-berlin.de/handle/')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'handle'" />
<xsl:value-of select="//datacite:identifier[lower-case(@identifierType)='handle'][contains(., '://hdl.handle.net/')]/substring-after(., '://hdl.handle.net/'),
//datacite:identifier[lower-case(@identifierType)='handle'][contains(., 'info:hdl:')]/substring-after(., 'info:hdl:'),
//datacite:identifier[lower-case(@identifierType)='handle'][contains(., '/handle/')]/substring-after(., '/handle/'),
//datacite:identifier[contains(., '://refubium.fu-berlin.de/handle/')]/substring-after(., '/handle/'),
//datacite:identifier[lower-case(@identifierType)='handle'][not(contains(., '://hdl.handle.net/')) and not(contains(., 'info:hdl:')) and not(contains(., '/handle/'))]" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = ('od______4225', 'r3110ae70d66') and not(//datacite:identifier[@identifierType='DOI'] and //datacite:identifier[@identifierType='URL'])">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'URL'" />
<xsl:value-of select="//datacite:identifier[@identifierType='URL']" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//dri:recordIdentifier[contains(., 'phaidra.univie.ac.at')] and //datacite:alternateIdentifier[@alternateIdentifierType='Handle' and starts-with(., '11353/10.')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'DOI'" />
<xsl:value-of select="//datacite:alternateIdentifier[@alternateIdentifierType='Handle' and starts-with(., '11353/10.')]" />
</datacite:identifier>
</xsl:when>
</xsl:choose>
</datacite:resource>
</metadata>
</record>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,791 @@
<!-- complete literature v4: xslt_cleaning_oaiOpenaire_datacite_ExchangeLandingpagePid ; transformation script production , 2021-02-17 -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oaf="http://namespace.openaire.eu/oaf"
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
xmlns:datacite="http://datacite.org/schema/kernel-4"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
xmlns:oaire="http://namespace.openaire.eu/schema/oaire/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vocabulary="http://eu/dnetlib/transform/clean"
xmlns:dateCleaner="http://eu/dnetlib/transform/dateISO"
exclude-result-prefixes="xsl vocabulary dateCleaner">
<xsl:param name="varOfficialName" />
<xsl:param name="varDsType" />
<xsl:param name="varDataSourceId" />
<xsl:param name="varFP7" select = "'corda_______::'"/>
<xsl:param name="varH2020" select = "'corda__h2020::'"/>
<xsl:param name="varAKA" select = "'aka_________::'"/>
<xsl:param name="varANR" select = "'anr_________::'"/>
<xsl:param name="varARC" select = "'arc_________::'"/>
<xsl:param name="varCHISTERA" select = "'chistera____::'"/>
<xsl:param name="varCONICYT" select = "'conicytf____::'"/>
<xsl:param name="varDFG" select = "'dfgf________::'"/>
<xsl:param name="varEUENVAGENCY" select = "'euenvagency_::'"/>
<xsl:param name="varFCT" select = "'fct_________::'"/>
<xsl:param name="varFWF" select = "'fwf_________::'"/>
<xsl:param name="varGSRI" select = "'gsri________::'"/>
<xsl:param name="varGSRT" select = "'gsrt________::'"/>
<xsl:param name="varHRZZ" select = "'irb_hr______::'"/> <!-- HRZZ not found -->
<xsl:param name="varINNOVIRIS" select = "'innoviris___::'"/>
<xsl:param name="varMESTD" select = "'mestd_______::'"/>
<xsl:param name="varMIUR" select = "'miur________::'"/>
<xsl:param name="varMZOS" select = "'irb_hr______::'"/>
<xsl:param name="varNHMRC" select = "'nhmrc_______::'"/>
<xsl:param name="varNIH" select = "'nih_________::'"/>
<xsl:param name="varNSF" select = "'nsf_________::'"/>
<xsl:param name="varNWO" select = "'nwo_________::'"/>
<xsl:param name="varRCUK" select = "'rcuk________::'"/> <!-- RCUK getting changed to UKRI -->
<xsl:param name="varRIF" select ="'rif_________::'"/>
<xsl:param name="varRSF" select ="'rsf_________::'"/>
<xsl:param name="varSFI" select ="'sfi_________::'"/>
<xsl:param name="varSFRS" select ="'sfrs________::'"/>
<xsl:param name="varSGOV" select = "'sgov________::'"/> <!-- SGOV to be added, awaiting DOI from Pilar, found project ids not in CSV list? -->
<xsl:param name="varSNSF" select = "'snsf________::'"/>
<xsl:param name="varTARA" select = "'taraexp_____::'"/> <!-- TARA to be added, awaiting DOI from André -->
<xsl:param name="varTUBITAK" select = "'tubitakf____::'"/>
<xsl:param name="varUKRI" select = "'ukri________::'"/> <!-- RCUK getting changed to UKRI -->
<xsl:param name="varWT" select = "'wt__________::'"/>
<xsl:param name="index" select="0"/>
<xsl:param name="transDate" select="current-dateTime()"/>
<!-- several different type statements in Refubium -->
<!-- toDo: apply priority levels -->
<xsl:variable name='varCobjCategory'
select="vocabulary:clean( //*[local-name()='resourceType']/@resourceTypeGeneral, 'dnet:publication_resource')"/>
<!-- select="vocabulary:clean( distinct-values(//*[local-name()='resourceType'][1]/@uri, 'dnet:publication_resource')" /-->
<xsl:variable name="varSuperType" select="vocabulary:clean( $varCobjCategory, 'dnet:result_typologies')"/>
<xsl:template match="/">
<xsl:variable name="datasourcePrefix"
select="normalize-space(//oaf:datasourceprefix)" />
<xsl:call-template name="validRecord" />
</xsl:template>
<xsl:template name="terminate">
<xsl:message terminate="yes">
record is not compliant, transformation is interrupted.
</xsl:message>
</xsl:template>
<xsl:template name="validRecord">
<record>
<xsl:apply-templates select="//*[local-name() = 'header']" />
<metadata>
<datacite:resource>
<xsl:choose>
<!-- cut off DOI resolver prefix to just get the number part -->
<xsl:when test="(//datacite:identifier, //datacite:alternateIdentifier)[@identifierType='DOI' or @alternateIdentifierType='DOI' or contains(., '://dx.doi.org/10.')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'DOI'"/>
<xsl:value-of select="//datacite:identifier[@identifierType='DOI'][contains(., '://dx.doi.org/')]/substring-after(., '://dx.doi.org/'),
(//datacite:identifier, //datacite:alternateIdentifier)[@identifierType='DOI' or @alternateIdentifierType='DOI'][not(contains(., '://dx.doi.org/'))],
//datacite:identifier[contains(., '://dx.doi.org/10.')]/substring-after(., '://dx.doi.org/')" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//datacite:identifier[lower-case(@identifierType)='handle'], //datacite:identifier[contains(., '://refubium.fu-berlin.de/handle/')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'handle'"/>
<xsl:value-of select="//datacite:identifier[lower-case(@identifierType)='handle'][contains(., '://hdl.handle.net/')]/substring-after(., '://hdl.handle.net/'),
//datacite:identifier[lower-case(@identifierType)='handle'][contains(., 'info:hdl:')]/substring-after(., 'info:hdl:'),
//datacite:identifier[lower-case(@identifierType)='handle'][contains(., '/handle/')]/substring-after(., '/handle/'),
//datacite:identifier[contains(., '://refubium.fu-berlin.de/handle/')]/substring-after(., '/handle/'),
//datacite:identifier[lower-case(@identifierType)='handle'][not(contains(., '://hdl.handle.net/')) and not(contains(., 'info:hdl:')) and not(contains(., '/handle/'))]" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = ('od______4225', 'r3110ae70d66') and not(//datacite:identifier[@identifierType='DOI'] and //datacite:identifier[@identifierType='URL'])">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'URL'"/>
<xsl:value-of select="//datacite:identifier[@identifierType='URL']" />
</datacite:identifier>
</xsl:when>
<xsl:when test="//dri:recordIdentifier[contains(., 'phaidra.univie.ac.at')] and //datacite:alternateIdentifier[@alternateIdentifierType='Handle' and starts-with(., '11353/10.')]">
<datacite:identifier>
<xsl:attribute name="identifierType" select="'DOI'"/>
<xsl:value-of select="//datacite:alternateIdentifier[@alternateIdentifierType='Handle' and starts-with(., '11353/10.')]" />
</datacite:identifier>
</xsl:when>
</xsl:choose>
<!-- specifically for Rothamsted -->
<datacite:alternateIdentifiers>
<xsl:choose>
<xsl:when test="//oaf:datasourceprefix = 'od______4225'">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="concat('https://repository.rothamsted.ac.uk/item/', substring-after(//dri:recordIdentifier, 'oai:repository.rothamsted.ac.uk:'))"/>
</datacite:alternateIdentifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = 'od______1318'">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="concat('https://orbi.uliege.be/handle/', substring-after(//dri:recordIdentifier, 'oai:orbi.ulg.ac.be:'))"/>
</datacite:alternateIdentifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = 'od______1514'">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="concat('http://uvadoc.uva.es/handle/', substring-after(//datacite:identifier, 'http://uvadoc.uva.es/handle/'))"/>
</datacite:alternateIdentifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = 'od______1388'">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="concat('http://rabida.uhu.es/dspace/handle/', substring-after(//dri:recordIdentifier, 'oai:rabida.uhu.es:'))"/>
</datacite:alternateIdentifier>
</xsl:when>
<xsl:when test="//oaf:datasourceprefix = 'od______1472'">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="concat('https://gredos.usal.es/handle/', substring-after(//dri:recordIdentifier, 'oai:gredos.usal.es:'))"/>
</datacite:alternateIdentifier>
</xsl:when>
<xsl:when test="contains(//dri:recordIdentifier, 'refubium.fu-berlin.de') or contains(//dri:recordIdentifier, 'www.qeios.com') or //*[local-name() = 'baseURL' and .= 'http://radar.brookes.ac.uk/radar/oai'] or contains(//dri:recordIdentifier, 'phaidra.univie.ac.at')">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'landingPage'"/>
<xsl:value-of select="//datacite:identifier[contains(., '://refubium.fu-berlin.de/') or contains(., '://www.qeios.com') or contains(., '://radar.brookes.ac.uk/radar/items/') or contains(., 'phaidra.univie.ac.at')]"/>
</datacite:alternateIdentifier>
</xsl:when>
</xsl:choose>
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)
[not($varCobjCategory = '0001' and ./@alternateIdentifierType = ('ISSN', 'EISSN'))]
[not($varCobjCategory = '0013' and ./@alternateIdentifierType = 'ISBN')]
[not(//oaf:datasourceprefix = 'od______4225' and ends-with(., 'pdf'))]
[not(//oaf:datasourceprefix = ('od______1562', 'od______4732'))]
[not(//oaf:datasourceprefix = 'od______1726' and ./@identifierType = 'URL')]
[not(contains(//dri:recordIdentifier, 'www.qeios.com'))]
[not(//*[local-name() = 'baseURL' and . = 'http://radar.brookes.ac.uk/radar/oai'])]
[not(@*[local-name()=('identifierType', 'alternateIdentifierType')]/lower-case(.) = ('doi', 'handle'))]">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="./@*[local-name()=('identifierType', 'alternateIdentifierType')]"/>
<xsl:value-of select="."/>
</datacite:alternateIdentifier>
</xsl:for-each>
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)[@*[local-name()=('identifierType', 'alternateIdentifierType')]/lower-case(.) = 'pmid']">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'URL'"/>
<xsl:value-of select="concat('https://www.ncbi.nlm.nih.gov/pubmed/', .)" />
</datacite:alternateIdentifier>
</xsl:for-each>
<!--
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)[@*[local-name()=('identifierType', 'alternateIdentifierType')]/lower-case(.) = ('handle')][//oaf:datasourceprefix = 'od______1318']">
</xsl:for-each>
-->
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)[@*[local-name()=('identifierType', 'alternateIdentifierType')]/lower-case(.) = ('handle')][//oaf:datasourceprefix = 'od______1726']">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'handle'"/>
<xsl:value-of select="." />
</datacite:alternateIdentifier>
</xsl:for-each>
<xsl:for-each select="distinct-values(((//datacite:alternateIdentifier, //datacite:identifier)[@*[local-name()=('identifierType', 'alternateIdentifierType')]/lower-case(.) = ('doi')][//oaf:datasourceprefix = 'od______1318']))">
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'DOI'"/>
<xsl:value-of select="substring-after(., 'info:doi:')" />
</datacite:alternateIdentifier>
<datacite:alternateIdentifier>
<xsl:attribute name="alternateIdentifierType" select="'URL'"/>
<xsl:value-of select="concat('http://dx.doi.org/', substring-after(., 'info:doi:'))" />
</datacite:alternateIdentifier>
</xsl:for-each>
</datacite:alternateIdentifiers>
<datacite:relatedIdentifiers>
<xsl:copy-of select="//datacite:relatedIdentifier" copy-namespaces="no"/>
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)
[$varCobjCategory = '0001' and ./@alternateIdentifierType = ('ISSN', 'EISSN')]">
<datacite:relatedIdentifier>
<xsl:attribute name="relatedIdentifierType" select="./@alternateIdentifierType"/>
<xsl:attribute name="relationType" select="'isPartOf'"/>
<xsl:value-of select="concat(substring(., 1, 4), '-', substring(., string-length(.)-3, 4))" />
</datacite:relatedIdentifier>
</xsl:for-each>
<xsl:for-each select="(//datacite:alternateIdentifier, //datacite:identifier)
[$varCobjCategory = '0013' and ./@alternateIdentifierType = 'ISBN']">
<datacite:relatedIdentifier>
<xsl:attribute name="relatedIdentifierType" select="'ISBN'"/>
<xsl:attribute name="relationType" select="'isPartOf'"/>
<xsl:value-of select="." />
</datacite:relatedIdentifier>
</xsl:for-each>
</datacite:relatedIdentifiers>
<xsl:for-each select="distinct-values(//dc:description)">
<datacite:description>
<xsl:attribute name="descriptionType" select="'Abstract'"/>
<xsl:value-of select="."/>
</datacite:description>
</xsl:for-each>
<xsl:for-each select="distinct-values(//dc:language)">
<datacite:language>
<xsl:value-of select="vocabulary:clean( ., 'dnet:languages')"/>
</datacite:language>
</xsl:for-each>
<xsl:if test="//dc:publisher">
<datacite:publisher>
<xsl:value-of select="//dc:publisher"/>
</datacite:publisher>
</xsl:if>
<!-- consider converting COAR version URIs -->
<xsl:if test="//oaire:version">
<datacite:version>
<xsl:value-of select="//oaire:version"/>
</datacite:version>
</xsl:if>
<!-- format -->
<xsl:for-each select="//dc:format">
<datacite:format>
<xsl:value-of select="."/>
</datacite:format>
</xsl:for-each>
<xsl:apply-templates select="(//*[local-name()='resource'], //*[local-name() = 'oai_openaire'])/datacite:*[not(local-name() = ('identifier', 'alternateIdentifiers', 'alternateIdentifier', 'relatedIdentifiers', 'relatedIdentifier'))]"/>
<xsl:apply-templates select="//*[local-name()='resource']/titles[//*[contains(., 'radar.brookes.ac.uk')]]"/>
<xsl:copy-of select="//*[local-name()='resource']//*[local-name() = 'title'][//*[contains(., 'radar.brookes.ac.uk')]]" copy-namespaces="no"/>
</datacite:resource>
<xsl:variable name='varEmbargoEndDate' select="dateCleaner:dateISO(normalize-space(//*[local-name()='date'][@dateType='Available']))"/>
<xsl:if test="//*[local-name()='date']/@dateType='Available' and //*[local-name()='datasourceprefix']!='r33ffb097cef'">
<xsl:choose>
<xsl:when test="string-length($varEmbargoEndDate) > 0">
<oaf:embargoenddate>
<xsl:value-of select="$varEmbargoEndDate"/>
</oaf:embargoenddate>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="terminate"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="lower-case(//*[local-name()='resourceType']/@resourceTypeGeneral)=('dataset', 'software', 'literature', 'other research product')">
<dr:CobjCategory>
<xsl:variable name="varCobjCategory"
select="vocabulary:clean( //*[local-name()='resourceType']/@resourceTypeGeneral, 'dnet:publication_resource')"/>
<xsl:variable name="varSuperType"
select="vocabulary:clean( $varCobjCategory, 'dnet:result_typologies')"/>
<xsl:attribute name="type">
<xsl:value-of select="$varSuperType"/>
</xsl:attribute>
<xsl:value-of select="$varCobjCategory"/>
</dr:CobjCategory>
<!--
<dr:CobjCategory>
<xsl:attribute name="type" select="//oaf:datasourceprefix[. = '_______qeios' and contains(//dri:recordIdentifier, '/definition/')]/'other', //oaf:datasourceprefix[not(. = '_______qeios' and contains(//dri:recordIdentifier, '/definition/'))]/$varSuperType"/>
<xsl:value-of select="$varCobjCategory" />
</dr:CobjCategory>
-->
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="terminate"/>
</xsl:otherwise>
</xsl:choose>
<!-- review status -->
<xsl:variable name="varRefereed" select="for $i in (//*[local-name() = 'resource']/*[local-name() = ('resourceType', 'version')]/(., @uri))
return vocabulary:clean( normalize-space($i), 'dnet:review_levels')"/>
<xsl:choose>
<xsl:when test="count($varRefereed[. = '0001']) > 0">
<oaf:refereed>
<xsl:value-of select="'0001'"/>
</oaf:refereed>
</xsl:when>
<xsl:when test="count($varRefereed[. = '0002']) > 0">
<oaf:refereed>
<xsl:value-of select="'0002'"/>
</oaf:refereed>
</xsl:when>
</xsl:choose>
<oaf:dateAccepted>
<xsl:value-of
select="dateCleaner:dateISO( normalize-space(//datacite:date[@dateType = 'Issued']))"/>
</oaf:dateAccepted>
<oaf:accessrights>
<xsl:variable name='varAccessRights'
select="vocabulary:clean( (//*[local-name() = 'rights']/@rightsURI, //*[local-name() = 'licenseCondition']/@uri)[1], 'dnet:access_modes')" />
<xsl:choose>
<xsl:when test="not($varAccessRights = 'EMBARGO' and not((xs:date( max( ($varEmbargoEndDate, '0001-01-01') ) ) gt current-date())))">
<xsl:value-of
select="vocabulary:clean( (//*[local-name() = 'rights']/@rightsURI, //*[local-name() = 'licenseCondition']/@uri)[1], 'dnet:access_modes')"/>
</xsl:when>
<xsl:when test="$varAccessRights = 'EMBARGO' and not((xs:date( max( ($varEmbargoEndDate, '0001-01-01') ) ) gt current-date()))">
<xsl:value-of select="'OPEN'"/>
</xsl:when>
</xsl:choose>
</oaf:accessrights>
<xsl:for-each select="distinct-values(//*[local-name()='licenseCondition']/(.[not(./@uri)][not(contains(., 'copyright')) and not(. = 'other')], .[./@uri]/@uri))">
<oaf:license>
<xsl:value-of select="."/>
</oaf:license>
</xsl:for-each>
<oaf:language>
<xsl:value-of select="vocabulary:clean( //*[local-name()='language'], 'dnet:languages')" />
</oaf:language>
<xsl:for-each select="//oaire:fundingReference[./oaire:awardNumber]">
<xsl:choose>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('European Commission', '10.13039/501100000780', '10.13039/100011102') and ./oaire:fundingStream = ('FP7', 'Framework Programme Seven', 'Seventh Framework Programme')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(./oaire:awardNumber[1], '.*(\d{6}).*', '$1'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('European Commission', '10.13039/501100000780', '10.13039/100010661') and ./oaire:fundingStream = ('H2020', 'Horizon 2020 Framework Programme')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Academy of Finland', 'Suomen Akatemia', 'Finlands Akademi', '10.13039/501100002341')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Agence Nationale de la Recherche', 'French National Research Agency', '10.13039/501100001665')">
<oaf:projectid>
<xsl:value-of select="concat($varANR, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('ARC', 'Australian Research Council', '10.13039/501100000923')">
<oaf:projectid>
<xsl:value-of select="concat($varARC, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('CHIST-ERA')">
<oaf:projectid>
<xsl:value-of select="concat($varCHISTERA, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Comisión Nacional de Investigación Científica y Tecnológica', '10.13039/501100002848')">
<oaf:projectid>
<xsl:value-of select="concat($varCONICYT, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('DFG', 'Deutsche Forschungsgemeinschaft', '10.13039/501100001659')">
<oaf:projectid>
<xsl:value-of select="concat($varDFG, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('European Environment Agency', '10.13039/501100000806')">
<oaf:projectid>
<xsl:value-of select="concat($varEUENVAGENCY, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('FCT', 'Fundação para a Ciência e Tecnologia', 'Fundação para a Ciência e a Tecnologia', '10.13039/501100001871')">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('FWF', 'Austrian Science Fund (FWF)', 'Austrian Science Fund', 'Fonds zur Förderung der Wissenschaftlichen Forschung', '10.13039/501100002428')">
<oaf:projectid>
<xsl:value-of select="concat($varFWF, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('General Secretariat for Research and Innovation')">
<oaf:projectid>
<xsl:value-of select="concat($varGSRI, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('GSRT', 'General Secretariat for Research and Technology', '10.13039/501100003448')">
<oaf:projectid>
<xsl:value-of select="concat($varGSRT, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('HRZZ', 'Hrvatska Zaklada za Znanost', 'Croatian Science Foundation', '10.13039/501100004488')">
<oaf:projectid>
<xsl:value-of select="concat($varHRZZ, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Innoviris', '10.13039/501100004744')">
<oaf:projectid>
<xsl:value-of select="concat($varINNOVIRIS, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja', '10.13039/501100004564')">
<oaf:projectid>
<xsl:value-of select="concat($varMESTD, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Ministero dellIstruzione, dellUniversità e della Ricerca', '10.13039/501100003407')">
<oaf:projectid>
<xsl:value-of select="concat($varMIUR, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Ministarstvo Znanosti, Obrazovanja i Sporta', 'Ministry of Science, Education and Sports', '10.13039/501100006588')">
<oaf:projectid>
<xsl:value-of select="concat($varMZOS, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('NHMRC', 'National Health and Medical Research Council', '10.13039/501100000925')">
<oaf:projectid>
<xsl:value-of select="concat($varNHMRC, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('National Institutes of Health', '10.13039/100000002')">
<oaf:projectid>
<xsl:value-of select="concat($varNIH, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('National Science Foundation', '10.13039/100000001')">
<oaf:projectid>
<xsl:value-of select="concat($varNSF, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Netherlands Organisation for Scientific Research', 'Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246')">
<oaf:projectid>
<xsl:value-of select="concat($varNWO, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('RCUK', 'Research Councils UK', '10.13039/501100000690')">
<oaf:projectid>
<xsl:value-of select="concat($varRCUK, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Research and Innovation Foundation')">
<oaf:projectid>
<xsl:value-of select="concat($varRIF, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Russian Science Foundation', '10.13039/501100006769')">
<oaf:projectid>
<xsl:value-of select="concat($varRSF, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('SFI', 'Science Foundation Ireland', 'SFI - Science Foundation Ireland', '10.13039/501100001602')">
<oaf:projectid>
<xsl:value-of select="concat($varSFI, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Science Fund of the Republic of Serbia')">
<oaf:projectid>
<xsl:value-of select="concat($varSFRS, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Gobierno de Espana', 'Gobierno de España')">
<oaf:projectid>
<xsl:value-of select="concat($varSGOV, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('SNSF', 'Swiss National Science Foundation', 'Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung', '10.13039/501100001711')">
<oaf:projectid>
<xsl:value-of select="concat($varSNSF, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Fondation Tara Expéditions', 'Tara Expedition')">
<oaf:projectid>
<xsl:value-of select="concat($varTARA, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Tubitak', 'Türkiye Bilimsel ve Teknolojik Araştırma Kurumu', 'Turkish National Science and Research Council', '10.13039/501100004410')">
<oaf:projectid>
<xsl:value-of select="concat($varTUBITAK, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('UK Research and Innovation', '10.13039/100014013')">
<oaf:projectid>
<xsl:value-of select="concat($varUKRI, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="(./oaire:funderName, ./oaire:funderIdentifier, ./oaire:funderIdentifier/substring-after(., 'doi.org/')) = ('Wellcome Trust', '10.13039/100010269')">
<oaf:projectid>
<xsl:value-of select="concat($varWT, ./oaire:awardNumber)"/>
</oaf:projectid>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<oaf:hostedBy>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId"/>
</xsl:attribute>
</oaf:hostedBy>
<oaf:collectedFrom>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId"/>
</xsl:attribute>
</oaf:collectedFrom>
<!-- oaf:journal -->
<!-- ISSN is erroneously stuffed in alternateIdentifier, should be put into relatedIdentifier -->
<!-- check/ensure that oaf:journal is not prepared for a journal itself, perhaps limit to Rothamsted -->
<!-- Huelva marks L, E ISSNs as ISSNs, with mark within field in spaces or after blanc -->
<!-- Qeios declares many records as text, although many seem to be definitions which are also related to 'journal' volumes/issues -->
<xsl:if test="($varCobjCategory = '0001' or contains(//dri:recordIdentifier, 'www.qeios.com')) and (//*[local-name() = 'alternateIdentifier']/@alternateIdentifierType[. = 'ISSN'] or //*[local-name() = 'relatedIdentifier'][lower-case(@relationType) = 'ispartof'][@relatedIdentifierType = 'ISSN'])">
<oaf:journal>
<xsl:attribute name="issn" select="(//*[local-name() = 'alternateIdentifier'][./@alternateIdentifierType = 'ISSN'], //*[local-name() = 'relatedIdentifier'][lower-case(./@relationType) = 'ispartof'][./@relatedIdentifierType = 'ISSN'])[1]/concat(substring(., 1, 4), '-', substring(., string-length(.)-3, 4))"/>
<xsl:if test="//*[local-name() = 'citationVolume']">
<xsl:attribute name="vol" select="//*[local-name() = 'citationVolume']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationIssue']">
<xsl:attribute name="iss" select="//*[local-name() = 'citationIssue']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationStartPage']">
<xsl:attribute name="sp" select="//*[local-name() = 'citationStartPage']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationEndPage']">
<xsl:attribute name="ep" select="//*[local-name() = 'citationEndPage']"/>
</xsl:if>
<xsl:value-of select="((//*[local-name() = 'citationTitle'], //dc:source[//oaf:datasourceprefix[.='od______1514']]))"/>
</oaf:journal>
</xsl:if>
<xsl:if test="$varCobjCategory = '0001' and //*[local-name() = 'relatedIdentifier']/@relatedIdentifierType[. = ('ISSN', 'PISSN', 'EISSN', 'LISSN')]">
<oaf:journal>
<xsl:for-each select="//*[local-name() = 'relatedIdentifier'][@relatedIdentifierType[. = ('ISSN', 'PISSN', 'EISSN', 'LISSN')]][@relationType/lower-case(.) = 'ispartof']">
<xsl:attribute name="{./@relatedIdentifierType}" select="./concat(substring(., 1, 4), '-', substring(., string-length(.)-3, 4))"/>
<!-- -->
</xsl:for-each>
<xsl:if test="//*[local-name() = 'citationVolume']">
<xsl:attribute name="vol" select="//*[local-name() = 'citationVolume']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationIssue']">
<xsl:attribute name="iss" select="//*[local-name() = 'citationIssue']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationStartPage']">
<xsl:attribute name="sp" select="//*[local-name() = 'citationStartPage']"/>
</xsl:if>
<xsl:if test="//*[local-name() = 'citationEndPage']">
<xsl:attribute name="ep" select="//*[local-name() = 'citationEndPage']"/>
</xsl:if>
<xsl:value-of select="((//oaire:citationTitle))"/>
</oaf:journal>
</xsl:if>
<!-- oaf:fulltext-->
<xsl:if test="//*[local-name() = 'file']">
<oaf:fulltext>
<xsl:value-of select="//*[local-name() = 'file']"/>
</oaf:fulltext>
</xsl:if>
</metadata>
<xsl:copy-of select="//*[local-name() = 'about']" />
</record>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
<!-- funding -->
<xsl:for-each select="//*[local-name()='fundingReference']">
<!-- FP7 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004963', '10.13039/100011199') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varFP7, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))"/>
</oaf:projectid>
</xsl:if>
<!-- H2020 -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100010661') and matches(./*[local-name()='awardNumber'], '.*(^|[^\d])\d\d\d\d\d\d($|[^\d]).*')">
<oaf:projectid>
<xsl:value-of select="concat($varH2020, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d)($|[^\d]).*', '$2'))"/>
</oaf:projectid>
</xsl:if>
<!-- AKA -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002341') or contains(./*[local-name()='funderName'], 'Suomen Akatemia') or contains(./*[local-name()='funderName'], 'Academy of Finland')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- ARC -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000923') or contains(./*[local-name()='funderName'], 'Australian Research Council')) and matches(./*[local-name()='awardNumber'], '^\d{6}$')">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, replace(./*[local-name()='awardNumber'], '.*(^\d{6}$).*', '$2'))"/>
</oaf:projectid>
</xsl:if>
<!-- CONICYT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002848') or contains(./*[local-name()='funderName'], 'Comisión Nacional de Investigación Científica y Tecnológica') or contains(./*[local-name()='funderName'], 'CONICYT')">
<oaf:projectid>
<xsl:value-of select="concat($varCONICYT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- DFG -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001659') or contains(./*[local-name()='funderName'], 'Deutsche Forschungsgemeinschaft') or contains(./*[local-name()='funderName'], 'DFG')">
<oaf:projectid>
<xsl:value-of select="concat($varDFG, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- FCT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or contains(./*[local-name()='funderName'], 'Fundação para a Ciência e a Tecnologia')">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- FWF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002428') or contains(./*[local-name()='funderName'], 'Fonds zur Förderung der Wissenschaftlichen Forschung') or contains(./*[local-name()='funderName'], 'Austrian Science Fund')">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- MESTD -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or (contains(./*[local-name()='funderName'], 'Ministarstvo Prosvete, Nauke i Tehnolo') and contains(./*[local-name()='funderName'], 'kog Razvoja')) or contains(./*[local-name()='funderName'], 'MESTD')">
<oaf:projectid>
<xsl:value-of select="concat($varMESTD, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- MZOS -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100006588') or contains(./*[local-name()='funderName'], 'Ministarstvo Znanosti, Obrazovanja i Sporta') or contains(./*[local-name()='funderName'], 'Ministry of Science, Education and Sports')">
<oaf:projectid>
<xsl:value-of select="concat($varMZOS, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- NHMRC -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000925') or contains(./*[local-name()='funderName'], 'National Health and Medical Research Council') or contains(./*[local-name()='funderName'], 'NHMRC')">
<oaf:projectid>
<xsl:value-of select="concat($varNHMRC, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- NIH -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100000002') or contains(./*[local-name()='funderName'], 'National Institutes of Health')">
<oaf:projectid>
<xsl:value-of select="concat($varNIH, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- NSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org') = ('10.13039/100000001') or contains(./*[local-name()='funderName'], 'National Science Foundation')">
<oaf:projectid>
<xsl:value-of select="concat($varNSF, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- NWO -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100003246') or contains(./*[local-name()='funderName'], 'Netherlands Organisation for Scientific Research') or contains(./*[local-name()='funderName'], 'Nederlandse Organisatie voor Wetenschappelijk Onderzoek')">
<oaf:projectid>
<xsl:value-of select="concat($varNWO, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- RCUK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000690') or contains(./*[local-name()='funderName'], 'Research Councils UK') or contains(./*[local-name()='funderName'], 'RCUK')">
<oaf:projectid>
<xsl:value-of select="concat($varRCUK, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- SFI -->
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001602') or contains(./*[local-name()='funderName'], 'Science Foundation Ireland')) and matches(./*[local-name()='awardNumber'], '.*([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+.*')">
<oaf:projectid>
<xsl:value-of select="concat($varSFI, replace(./*[local-name()='awardNumber'], '.*(^|\s)(([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+)($|\s).*', '$2'))"/>
</oaf:projectid>
</xsl:if>
<!-- SNSF -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001711') or contains(./*[local-name()='funderName'], 'Swiss National Science Foundation') or contains(./*[local-name()='funderName'], 'Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung') or (./*[local-name()='funderName' and . = 'SNSF'])">
<oaf:projectid>
<xsl:value-of select="concat($varSNSF, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- TUBITAK -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100004410') or contains(./*[local-name()='funderName'], 'Turkish National Science and Research Council') or (contains(./*[local-name()='funderName'], 'Türkiye Bilimsel ve Teknolojik Ara') and contains(./*[local-name()='funderName'], 'rma Kurumu'))">
<oaf:projectid>
<xsl:value-of select="concat($varTUBITAK, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
<!-- WT -->
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100004440') or contains(./*[local-name()='funderName'], 'Wellcome Trust')">
<oaf:projectid>
<xsl:value-of select="concat($varWT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="//*[local-name() = 'header']">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:element name="dr:dateOfTransformation">
<xsl:value-of select="$transDate"/>
</xsl:element>
</xsl:copy>
</xsl:template>
<!-- ToDo: drop URLs for DOIs? -->
</xsl:stylesheet>

View File

@ -0,0 +1,451 @@
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oaf="http://namespace.openaire.eu/oaf"
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
xmlns:datacite="http://datacite.org/schema/kernel-4"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
xmlns:oaire="http://namespace.openaire.eu/schema/oaire/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:vocabulary="http://eu/dnetlib/transform/clean"
xmlns:dateCleaner="http://eu/dnetlib/transform/dateISO"
exclude-result-prefixes="xsl vocabulary dateCleaner">
<xsl:param name="varOfficialName"/>
<xsl:param name="varDsType"/>
<xsl:param name="varDataSourceId"/>
<xsl:param name="varFP7" select="'corda_______::'"/>
<xsl:param name="varH2020" select="'corda__h2020::'"/>
<xsl:param name="varAKA" select="'aka_________::'"/>
<xsl:param name="varARC" select="'arc_________::'"/>
<xsl:param name="varCONICYT" select="'conicytf____::'"/>
<xsl:param name="varDFG" select="'dfgf________::'"/>
<xsl:param name="varFCT" select="'fct_________::'"/>
<xsl:param name="varFWF" select="'fwf_________::'"/>
<xsl:param name="varHRZZ" select="'irb_hr______::'"/>
<xsl:param name="varMESTD" select="'mestd_______::'"/>
<xsl:param name="varMZOS" select="'irb_hr______::'"/>
<xsl:param name="varNHMRC" select="'nhmrc_______::'"/>
<xsl:param name="varNIH" select="'nih_________::'"/>
<xsl:param name="varNSF" select="'nsf_________::'"/>
<xsl:param name="varNWO" select="'nwo_________::'"/>
<xsl:param name="varRCUK" select="'rcuk________::'"/>
<xsl:param name="varSFI" select="'sfi_________::'"/>
<xsl:param name="varSGOV"
select="'sgov________::'"/> <!-- SGOV awaiting DOI from Pilar, found project ids not in CSV list? -->
<xsl:param name="varSNSF" select="'snsf________::'"/>
<xsl:param name="varTARA" select="'taraexp_____::'"/> <!-- TARA awaiting DOI from André -->
<xsl:param name="varTUBITAK" select="'tubitakf____::'"/>
<xsl:param name="varWT" select="'wt__________::'"/>
<xsl:param name="index" select="0"/>
<xsl:param name="transDate" select="current-dateTime()"/>
<xsl:template match="/">
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)"/>
<xsl:call-template name="validRecord"/>
</xsl:template>
<xsl:template name="validRecord">
<record>
<xsl:apply-templates select="//*[local-name() = 'header']"/>
<metadata>
<xsl:apply-templates select="//*[local-name() = 'metadata']//*[local-name() = 'resource']"/>
<xsl:if test="//*[local-name()='date']/@dateType='Available'">
<xsl:variable name='varEmbargoEndDate'
select="dateCleaner:dateISO(normalize-space(//*[local-name()='date'][@dateType='Available']))"/>
<xsl:choose>
<xsl:when test="string-length($varEmbargoEndDate) > 0">
<oaf:embargoenddate>
<xsl:value-of select="$varEmbargoEndDate"/>
</oaf:embargoenddate>
</xsl:when>
<xsl:otherwise>
<oaf:skip>
<invalid/>
</oaf:skip>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<dr:CobjCategory>
<xsl:variable name="varCobjCategory"
select="vocabulary:clean( //*[local-name()='resourceType']/@resourceTypeGeneral, 'dnet:publication_resource')"/>
<xsl:variable name="varSuperType"
select="vocabulary:clean( $varCobjCategory, 'dnet:result_typologies')"/>
<xsl:attribute name="type">
<xsl:value-of select="$varSuperType"/>
</xsl:attribute>
<xsl:value-of select="$varCobjCategory"/>
</dr:CobjCategory>
<!-- review status -->
<!-- Zenodo -->
<xsl:variable name="varRefereedConvt" select="for $i in (//*[local-name()='resourceType']/(., @resourceTypeGeneral), //*[local-name()='version'])
return vocabulary:clean(normalize-space($i), 'dnet:review_levels')"/>
<xsl:variable name="varRefereedIdntf"
select="//*[local-name()=('identifier', 'alternateIdentifier')][matches(lower-case(.), '.*([\s\-\.\\_/:]|%[2-7][0-9A-F])pre([\s\-\.\\_/:]|%[2-7][0-9A-F])?prints?([\s\-\.\\_/:%].*|$)')]/'0002' "/>
<xsl:variable name="varRefereedReltn"
select="//*[local-name()='relatedIdentifier'][./@relationType/lower-case(.)='isreviewedby']/'0001' "/>
<xsl:variable name="varRefereedVersn" select="(//*[local-name()='version'][matches(lower-case(.), '.*peer[\s\-\.\\_/:%]?reviewed.*')]/'0001',
//*[local-name()='version'][matches(normalize-space(lower-case(.)), '^(v|vs|version|rel|release)?[\s\.\-_]*0$')]/'0002',
//*[local-name()='version'][matches(lower-case(.), '(^|[\s\-\.\\_/:%].*)(beta|draft|trial|test)([\s\-\.\\_/:%].*|$)')]/'0002',
//*[local-name()='version'][matches(lower-case(.), '.*submi(tted|ssion|ttal).*')]/'0002') "/>
<xsl:variable name="varRefereedOther" select="(//*[local-name()='publisher'][matches(lower-case(.), '.*[\s\-\.\\_/:%]pre[\s\-\.\\_/:%]?prints?([\s\-\.\\_/:%].*|$)')]/'0002',
//*[local-name()='description'][matches(lower-case(.), '^peer[\s\-\.\\_/:%]?reviewed$')]/'0001',
//*[local-name()='description'][matches(lower-case(.), '^pre[\s\-\.\\_/:%]?prints?$')]/'0002') "/>
<xsl:variable name="varRefereed"
select="($varRefereedConvt, $varRefereedIdntf, $varRefereedReltn, $varRefereedVersn, $varRefereedOther)"/>
<xsl:choose>
<xsl:when test="count($varRefereed[. = '0001']) > 0">
<oaf:refereed>
<xsl:value-of select="'0001'"/>
</oaf:refereed>
</xsl:when>
<xsl:when test="count($varRefereed[. = '0002']) > 0">
<oaf:refereed>
<xsl:value-of select="'0002'"/>
</oaf:refereed>
</xsl:when>
</xsl:choose>
<oaf:dateAccepted>
<xsl:value-of
select="dateCleaner:dateISO(normalize-space(//*[local-name()='publicationYear']))"/>
</oaf:dateAccepted>
<xsl:choose>
<xsl:when
test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
<oaf:accessrights>
<xsl:value-of
select="vocabulary:clean( //*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'dnet:access_modes')"/>
</oaf:accessrights>
</xsl:when>
<xsl:when
test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
<oaf:accessrights>
<xsl:value-of
select="vocabulary:clean( //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'dnet:access_modes')"/>
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when
test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org')]">
<oaf:accessrights>
<xsl:text>OPEN</xsl:text>
</oaf:accessrights>
</xsl:when>
<xsl:otherwise>
<oaf:accessrights>
<xsl:text>CLOSED</xsl:text>
</oaf:accessrights>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<oaf:language>
<xsl:value-of
select="vocabulary:clean(//*[local-name()='language'], 'dnet:languages')"/>
</oaf:language>
<xsl:for-each
select="//*[local-name()='nameIdentifier'][contains(., 'info:eu-repo/grantAgreement/')], //*[local-name()='fundingReference']/*[local-name()='awardNumber']">
<xsl:choose>
<xsl:when
test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/100011102']">
<oaf:projectid>
<xsl:value-of
select="concat($varFP7, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100000780']">
<oaf:projectid>
<xsl:value-of
select="concat($varH2020, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/aka/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100002341']">
<oaf:projectid>
<xsl:value-of
select="concat($varAKA, replace(normalize-space(.), '(info:eu-repo/grantagreement/aka/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/arc/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100000923']">
<oaf:projectid>
<xsl:value-of
select="concat($varARC, replace(normalize-space(.), '(info:eu-repo/grantagreement/arc/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/conicyt/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100002848']">
<oaf:projectid>
<xsl:value-of
select="concat($varCONICYT, replace(normalize-space(.), '(info:eu-repo/grantagreement/conicyt/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/dfg/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100001659']">
<oaf:projectid>
<xsl:value-of
select="concat($varDFG, replace(normalize-space(.), '(info:eu-repo/grantagreement/dfg/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/fct/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100001871']">
<oaf:projectid>
<xsl:value-of
select="concat($varFCT, replace(normalize-space(.), '(info:eu-repo/grantagreement/fct/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/fwf/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100002428']">
<oaf:projectid>
<xsl:value-of
select="concat($varFWF, replace(normalize-space(.), '(info:eu-repo/grantagreement/fwf/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/hrzz/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100004488']">
<oaf:projectid>
<xsl:value-of
select="concat($varHRZZ, replace(normalize-space(.), '(info:eu-repo/grantagreement/hrzz/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="matches(normalize-space(.), 'info:eu-repo/grantagreement/mestd/.*', 'i')">
<oaf:projectid>
<xsl:value-of
select="concat($varMESTD, replace(normalize-space(.), '(info:eu-repo/grantagreement/mestd/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="matches(normalize-space(.), 'info:eu-repo/grantagreement/mzos/.*', 'i')">
<oaf:projectid>
<xsl:value-of
select="concat($varMZOS, replace(normalize-space(.), '(info:eu-repo/grantagreement/mzos/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/nhmrc/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100000925']">
<oaf:projectid>
<xsl:value-of
select="concat($varNHMRC, replace(normalize-space(.), '(info:eu-repo/grantagreement/nhmrc/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/nih/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/100000002']">
<oaf:projectid>
<xsl:value-of
select="concat($varNIH, replace(normalize-space(.), '(info:eu-repo/grantagreement/nih/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/nsf/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/100000001']">
<oaf:projectid>
<xsl:value-of
select="concat($varNSF, replace(normalize-space(.), '(info:eu-repo/grantagreement/nsf/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/nwo/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100003246']">
<oaf:projectid>
<xsl:value-of
select="concat($varNWO, replace(normalize-space(.), '(info:eu-repo/grantagreement/nwo/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/rcuk/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100000690']">
<oaf:projectid>
<xsl:value-of
select="concat($varRCUK, replace(normalize-space(.), '(info:eu-repo/grantagreement/rcuk/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/sfi/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100001602']">
<oaf:projectid>
<xsl:value-of
select="concat($varSFI, replace(normalize-space(.), '(info:eu-repo/grantagreement/sfi/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="matches(normalize-space(.), 'info:eu-repo/grantagreement/sgov/.*', 'i')">
<oaf:projectid>
<xsl:value-of
select="concat($varSGOV, replace(normalize-space(.), '(info:eu-repo/grantagreement/sgov/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/snsf/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100001711']">
<oaf:projectid>
<xsl:value-of
select="concat($varSNSF, replace(normalize-space(.), '(info:eu-repo/grantagreement/snsf/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when test="matches(normalize-space(.), 'info:eu-repo/grantagreement/tara/.*', 'i')">
<oaf:projectid>
<xsl:value-of
select="concat($varTARA, replace(normalize-space(.), '(info:eu-repo/grantagreement/tara/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/tubitak/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/501100004410']">
<oaf:projectid>
<xsl:value-of
select="concat($varTUBITAK, replace(normalize-space(.), '(info:eu-repo/grantagreement/tubitak/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
<xsl:when
test="matches(normalize-space(.), 'info:eu-repo/grantagreement/wt/.*', 'i') or ../*[local-name() = 'funderIdentifier' and . = '10.13039/100004440']">
<oaf:projectid>
<xsl:value-of
select="concat($varWT, replace(normalize-space(.), '(info:eu-repo/grantagreement/wt/.*?/)([^/]*)(/.*)?', '$2', 'i'))"/>
</oaf:projectid>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="//*[local-name()='relatedIdentifier']">
<xsl:if
test="starts-with(./text(), 'https://zenodo.org/communities/')">
<oaf:concept>
<xsl:attribute name="id">
<xsl:value-of select="./text()"/>
</xsl:attribute>
</oaf:concept>
</xsl:if>
</xsl:for-each>
<oaf:hostedBy>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId"/>
</xsl:attribute>
</oaf:hostedBy>
<oaf:collectedFrom>
<xsl:attribute name="name">
<xsl:value-of select="$varOfficialName"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$varDataSourceId"/>
</xsl:attribute>
</oaf:collectedFrom>
</metadata>
<xsl:copy-of select="//*[local-name() = 'about']"/>
</record>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers']">
<xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:copy-of select="./*"/>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://hdl.handle.net/', //*[local-name() = 'resource']/*[local-name()='identifier'])"/>
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://nbn-resolving.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])"/>
</xsl:element>
</xsl:if>
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://dx.doi.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
<xsl:copy-of select="."/>
<xsl:if test="not(//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers'])">
<xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:if test=".[@identifierType='Handle']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://hdl.handle.net/', .)"/>
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='URN']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://nbn-resolving.org/', .)"/>
</xsl:element>
</xsl:if>
<xsl:if test=".[@identifierType='DOI']">
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
<xsl:attribute name="alternateIdentifierType">
<xsl:value-of select="'URL'"/>
</xsl:attribute>
<xsl:value-of
select="concat('http://dx.doi.org/', .)"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="//*[local-name() = 'header']">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:element name="dr:dateOfTransformation">
<xsl:value-of select="$transDate"/>
</xsl:element>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -33,6 +33,10 @@
</execution>
</executions>
<configuration>
<args>
<arg>-Xmax-classfile-name</arg>
<arg>140</arg>
</args>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>

View File

@ -685,6 +685,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.failsave.plugin.version>2.22.2</maven.failsave.plugin.version>
<properties.maven.plugin.version>2.0.1</properties.maven.plugin.version>
<dhp.cdh.version>cdh5.9.2</dhp.cdh.version>