Compare commits

...

1 Commits

2 changed files with 443 additions and 0 deletions

View File

@ -26,17 +26,27 @@ dri:recordIdentifier = xpath:"//dri:recordIdentifier";
// apply xpath:"//dc:contributor[starts-with(., 'European Project')]" if xpath:"string-length(replace(., '.*(\d{6,6}).*', '$1')) = 6" oaf:projectid = xpath:"concat($var1, replace(., '.*(\d{6,6}).*', '$1'))"; else $varDummy = "''";
apply xpath:"//dc:creator" if xpath:"string-length(.) > 0 and normalize-space(.) != ','" dc:creator = xpath:"normalize-space(.)"; else $varDummy = "''";
if xpath:"//dc:title[string-length(.)> 0]" $varDummy = "''"; else dc:coverage = skipRecord();
dc:title = xpath:"//dc:title[string-length(.) > 0]/normalize-space(.)";
apply xpath:"//dc:subject" if xpath:"string-length(.) > 0" dc:subject = xpath:"normalize-space(.)"; else $varDummy = "''";
apply xpath:"//dc:publisher" if xpath:"string-length(.) > 0" dc:publisher = xpath:"normalize-space(.)"; else $varDummy = "''";
TODO
apply xpath:"//dc:source" if xpath:"string-length(.) > 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
TODO
dc:contributor = xpath:"//dc:contributor";
// dc:description = xpath:"//dc:description/normalize-space(.)";
//dc:description = xpath:"string-join(//dc:description/normalize-space(.), concat('; ',codepoints-to-string(10)))";
dc:description = xpath:"string-join(//dc:description/normalize-space(.), '; ')";
dc:format = xpath:"//dc:format";
$varHttpTest = "''";
oaf:fulltext = xpath:"//dc:identifier[starts-with(., 'http') and (ends-with(., 'document') or ends-with(., 'pdf'))]";
//if xpath:"//dc:identifier[starts-with(., 'http') and (ends-with(., 'document') or ends-with(., 'pdf'))] or //dc:relation[starts-with(lower-case(normalize-space(.)), 'info:eu-repo/grantagreement')] or //dc:rights[starts-with(lower-case(normalize-space(.)), 'open') or contains(lower-case(normalize-space(.)), 'openaccess')] or //dc:accessRights[contains(lower-case(normalize-space(.)), 'openaccess')]" $var0 = "''"; else dc:coverage = skipRecord();
if xpath:"//dc:identifier[starts-with(., 'http')]" $var0 = "''"; else dc:coverage = skipRecord();
apply xpath:"//dc:identifier" if xpath:"starts-with(normalize-space(.), 'http')" dc:identifier = xpath:"normalize-space(.)"; else dr:CobjIdentifier = xpath:"normalize-space(.)";
@ -46,6 +56,8 @@ dc:type = xpath:"//dc:type";
dc:format = xpath:"//dc:format";
dc:date = xpath:"//dc:date";
dc:language = Convert(xpath:"//dc:language", Languages);
$varDateAccepted = Convert(xpath:"descendant-or-self::dc:date", DateISO8601, "yyyy-MM-dd", "min()");
if xpath:"starts-with($varDateAccepted, '0')" oaf:dateAccepted = $varDummy; else oaf:dateAccepted = $varDateAccepted;
$varEmbargoEnd = xpath:"//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')";

View File

@ -0,0 +1,431 @@
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:datacite="http://datacite.org/schema/kernel-4"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:oaire="http://namespace.openaire.eu/schema/oaire/"
xmlns:oaf="http://namespace.openaire.eu/oaf"
xmlns:dateCleaner="http://eu/dnetlib/transform/dateISO"
xmlns:vocabulary="http://eu/dnetlib/transform/clean"
exclude-result-prefixes="xsl vocabulary dateCleaner">
<xsl:param name="varOfficialName"/>
<xsl:param name="varDataSourceId"/>
<xsl:param name="varAKA" select="'aka_________::'"/>
<xsl:param name="varARC" select="'arc_________::'"/>
<xsl:param name="varANR" select="'anr_________::'"/>
<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="varFP7" select="'corda_______::'"/>
<xsl:param name="varFWF" select="'fwf_________::'"/>
<xsl:param name="varGSRI" select="'gsri________::'"/>
<xsl:param name="varGSRT" select="'gsrt________::'"/>
<xsl:param name="varH2020" select="'corda__h2020::'"/>
<xsl:param name="varHEUROPE" select="'corda_____he::'"/>
<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="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________::'"/><!-- UKRI replace RCUK namespace: 'rcuk________::' -->
<xsl:param name="varWT" select="'wt__________::'"/>
<xsl:param name="index" select="0"/>
<xsl:param name="transDate" select="current-dateTime()"/>
<xsl:template match="/">
<xsl:if test="//oai:header/@status='deleted'">
<xsl:call-template name="terminate"/>
</xsl:if>
<xsl:if test="string-length(//*[local-name() = 'date'][1]) &lt; 4">
<xsl:call-template name="terminate"/>
</xsl:if>
<xsl:call-template name="validRecord"/>
</xsl:template>
<xsl:template name="terminate">
<xsl:message terminate="yes">
record is not compliant, skip transformation.
</xsl:message>
</xsl:template>
<xsl:template match="//*[local-name() = 'header']">
<header xmlns="http://www.openarchives.org/OAI/2.0/">
<!--
<xsl:copy copy-namespaces="no">
-->
<xsl:apply-templates select="node()|@*"/>
<xsl:element name="dr:dateOfTransformation">
<xsl:value-of select="$transDate"/>
</xsl:element>
<!--
</xsl:copy>
-->
</header>
</xsl:template>
<xsl:template name="validRecord">
<xsl:variable name="varEmbargoEndDate" select="dateCleaner:dateISO(normalize-space(//*[local-name()='date'][@dateType='Available']))"/><!-- resourceType, superType -->
<xsl:variable name="varCobjCategory" select="vocabulary:clean( //*[local-name()='type'], 'dnet:publication_resource')"/>
<xsl:variable name="varSuperType" select="vocabulary:clean( $varCobjCategory, 'dnet:result_typologies')"/>
<!-- $varIdDoi = identifierExtract('["//dc:identifier[starts-with(., \"info:\")
or starts-with(., \"urn:\")
or starts-with(., \"doi:\")
or starts-with(., \"DOI:\")
or starts-with(., \"Doi:\")
or starts-with(., \"doi \")
or starts-with(., \"DOI \")
or starts-with(., \"Doi \")
or starts-with(., \"10.\")
or ((starts-with(., \"http\"))
and contains(., \"doi.org/10.\"))
]",
"//dc:relation[starts-with(., \"info:eu-repo/semantics/altIdentifier/doi/10.\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/DOI/10.\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/Doi/10.\")
or ((starts-with(., \"info:eu-repo/semantics/altIdentifier/url/http\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/purl/http\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/urn/http\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/doi/http\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/DOI/http\")
or starts-with(., \"info:eu-repo/semantics/altIdentifier/Doi/http\"))
and contains(., \"doi.org/10.\"))]"
]' ,
xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/&lt;&gt;]*/[^\s"&lt;&gt;]+)'); -->
<xsl:variable name="varPidDoi" select="concat(' DOI:::', string-join(distinct-values((
(//dc:identifier)[contains(., 'doi.org/10.')]/lower-case(substring-after(., 'doi.org/')), (//datacite:identifier, //datacite:alternateIdentifier)[contains(., 'info:doi:')]/substring-after(., 'info:doi:'), (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='doi'][not(contains(., 'doi.org/10.')) and not(contains(., 'info:doi:')) and not(contains(., '/doi/'))]/lower-case(.), (//datacite:identifier, //datacite:alternateIdentifier)[matches(., '.*/doi/.*/10\..*')]/replace(., '.*/doi/.*/(10\..*)$', '$1') )), ' DOI:::'))"/>
<xsl:variable name="varPidHandle" select="concat(' Handle:::', string-join(distinct-values((
(//dc:identifier)[contains(., 'hdl.handle.net/')][not(contains(., '123456789'))]/substring-after(., 'hdl.handle.net/'), (//datacite:identifier, //datacite:alternateIdentifier)[contains(., 'info:hdl:')][not(contains(., '123456789'))]/substring-after(., 'info:hdl:'), (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='handle'][not(starts-with(., 'http')) and not(contains(., 'hdl.handle.net/')) and not(contains(., 'info:hdl:')) and not(contains(., '/handle/123456789/'))] )), ' Handle:::'))"/>
<xsl:variable name="varPidUrn" select="concat(' URN:::', string-join(distinct-values((
(//dc:identifier)[starts-with(lower-case(.), 'urn:nbn:')]/concat('urn:nbn:', substring-after(lower-case(.), 'urn:nbn:')), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(lower-case(.), 'http') and (contains(lower-case(.), '://nbn-resolving.org/urn:nbn:') or contains(lower-case(.), '://nbn-resolving.de/urn/resolver.pl?urn:nbn:') or contains(lower-case(.), '://nbn-resolving.de/urn:nbn:') or contains(lower-case(.), '://resolver.obvsg.at/urn:nbn:') or contains(lower-case(.), '://urn.fi/urn:nbn:') or contains(lower-case(.), '://urn.kb.se/resolve?urn=urn:nbn:'))]/concat('urn:nbn:', substring-after(lower-case(.), 'urn:nbn:')) )), ' URN:::'))"/>
<xsl:variable name="varPidArk" select="concat(' ARK:::', string-join(distinct-values((
(//dc:identifier)[starts-with(., 'http') and contains(., '/ark:/')]/concat('ark:/', substring-after(., '/ark:/')) )), ' ARK:::'))"/>
<xsl:variable name="varPidPmid" select="concat(' PMID:::', string-join(distinct-values((
(//dc:identifier)[starts-with(., 'http') and contains(., '://www.ncbi.nlm.nih.gov/pmc/articles/')]/substring-after(., '://www.ncbi.nlm.nih.gov/pmc/articles/'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(., 'info:pmid/')]/substring-after(., 'info:pmid/'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(lower-case(.), 'pmid:') or starts-with(lower-case(.), 'pubmed:')]/substring-after(., ':'), (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='pmc'][not(contains(., 'ncbi.nlm.nih.gov'))][not(contains(., ':'))], (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='pmid'][not(contains(., ':'))] )), ' PMID:::'))"/>
<xsl:variable name="varPidPmcid" select="concat(' PMCID:::', string-join(distinct-values((
(//dc:identifier)[starts-with(., 'http') and (contains(lower-case(.), '://www.ncbi.nlm.nih.gov/pmc/articles/pmc') or contains(lower-case(.), '://europepmc.org/articles/pmc'))]/substring-after(., '/articles/'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(lower-case(.), 'pmcid:') or starts-with(lower-case(.), 'pmc:')]/substring-after(., ':'), (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='pmcid'] )), ' PMCID:::'))"/>
<xsl:variable name="varPidHal" select="concat(' HAL:::', string-join(distinct-values((
(//dc:identifier)[lower-case(@*)='hal' and (starts-with(., 'hal-') or starts-with(., 'halshs-') or starts-with(., 'halsde-'))], (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(., 'http') and (contains(., '://hal.archives-ouvertes.fr/hal') or contains(., '://hal.inria.fr/hal') or contains(., '://halshs.archives-ouvertes.fr/hal') or contains(., '://halsde.archives-ouvertes.fr/hal'))]/substring-after(., '.fr/') )), ' HAL:::'))"/>
<xsl:variable name="varPidBibc" select="concat(' BIBC:::', string-join(distinct-values((
(//dc:identifier)[starts-with(lower-case(.), 'bibcode:')]/substring-after(lower-case(.), 'bibcode:'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(., 'http') and contains(lower-case(.), 'bibcode=')]/substring(substring-after(lower-case(.), 'bibcode='), 1, 19) )), ' BIBC:::'))"/>
<xsl:variable name="varPidArxiv" select="concat(' arXiv:::', string-join(distinct-values((
(//dc:identifier)[starts-with(lower-case(.), 'arxiv:')]/substring-after(lower-case(.), 'arxiv:'), (//datacite:identifier, //datacite:alternateIdentifier)[(starts-with(., 'http') or starts-with(lower-case(.), 'arxiv: http')) and contains(., '://arxiv.org/abs/')]/substring-after(., '://arxiv.org/abs/'), (//datacite:identifier, //datacite:alternateIdentifier)[(starts-with(., 'http') or starts-with(lower-case(.), 'arxiv: http')) and contains(., '://arxiv.org/pdf/')]/substring-before(substring-after(lower-case(.), '://arxiv.org/pdf/'), '.pdf'), (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='arxiv'] )), ' arXiv:::'))"/>
<xsl:variable name="varPidWos" select="concat(' WOS:::', string-join(distinct-values((
(//dc:identifier)[lower-case(@*)='wos'][not(starts-with(lower-case(.), 'wos:'))], (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(lower-case(.), 'wos:') and not(starts-with(lower-case(.), 'wos: wos:'))]/substring-after(lower-case(.), 'wos:'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(lower-case(.), 'wos: wos:')]/substring-after(lower-case(.), 'wos: wos:') )), ' WOS:::'))"/>
<xsl:variable name="varPidScp" select="concat(' SCP:::', string-join(distinct-values((
(//dc:identifier)[starts-with(lower-case(.), 'scopus_id:') or starts-with(lower-case(.), 'scopus:')]/substring-after(., ':'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(normalize-space(.), 'scopus: eid=')]/substring-after(., 'eid=2-s2.0-'), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(normalize-space(.), 'http') and contains(., '://www.scopus.com/inward/record.ur') and contains(., 'scp=')]/substring-after(., 'scp='), (//datacite:identifier, //datacite:alternateIdentifier)[starts-with(normalize-space(.), 'http') and contains(., '://www.scopus.com/inward/record.ur') and contains(., 'eid=2-s2.0-')]/substring-after(., 'eid=2-s2.0-') )), ' SCP:::'))"/>
<xsl:variable name="varPidUrl" select="concat(' URL:::', string-join(distinct-values((
(//dc:identifier)[lower-case(@*)='url'] [not(contains(., 'doi.org/10.')) and not(contains(., 'info:doi:')) and not(matches(., '.*/doi/.*/10\..*'))] [not(contains(., 'hdl.handle.net/')) and not(contains(., 'info:hdl:'))] [not(contains(., '://www.ncbi.nlm.nih.gov/pmc/articles/'))] [not(. = $varLandingPage)] )), ' URL:::'))"/>
<xsl:variable name="varPidIsbn" select="concat(' ISBN:::', string-join(distinct-values((
(//dc:identifier)[lower-case(@*)='isbn' and not(contains(., ':')) and not($varCobjCategory = '0013')], (//datacite:identifier, //datacite:alternateIdentifier)[lower-case(@*)='isbn' and starts-with(lower-case(.), 'urn:isbn') and not($varCobjCategory = '0013')]/substring-after(lower-case(.), 'urn:isbn:') )), ' ISBN:::'))"/>
<xsl:variable name="varPidIssn" select="string-join(distinct-values((
(//dc:identifier)[lower-case(@*)=('issn', 'pissn', 'eissn', 'lissn') and matches(., '.*\d{4}[\s-]?\d{3}[\dXx].*') and not($varCobjCategory = '0001')]/concat(' ', upper-case((@identifierType, @alternateIdentifierType)), ':::', replace(., '^.*(\d{4})[\s-]?(\d{3}[\dXx]).*$', '$1-$2')) )), '')"/><!-- heap all IDs, drop landingPage URL -->
<xsl:variable name="varPidPre" select="concat($varPidDoi[not(. = ' DOI:::')],
$varPidHandle[not(. = ' Handle:::')],
$varPidUrn[not(. = ' URN:::')],
$varPidArk[not(. = ' ARK:::')],
$varPidPmid[not(. = ' PMID:::')],
$varPidPmcid[not(. = ' PMCID:::')],
$varPidHal[not(. = ' HAL:::')],
$varPidBibc[not(. = ' BIBC:::')],
$varPidArxiv[not(. = ' arXiv:::')],
$varPidWos[not(. = ' WOS:::')],
$varPidScp[not(. = ' SCP:::')],
$varPidUrl[not(. = ' URL:::')],
$varPidIsbn[not(. = ' ISBN:::')],
$varPidIssn[not(. = ' ISSN:::')])"/>
<!--
<xsl:variable name="varPid" select="concat($varPidPre, $varLandingPage[string-length($varPidPre) = 0]/concat('landingPage:::', .))"/>
<xsl:variable name="varPid" select="concat($varPidPre, concat(' landingPage:::', $varLandingPage[string-length($varPidPre) = 0], .))"/>
-->
<xsl:variable name="varPid" select="concat($varPidPre, //oaf:datasourceprefix[string-length($varPidPre) = 0]/concat(' landingPage:::', $varLandingPage))"/><!-- relatedIdentifier --><!-- container PIDs (ISSNs, ISBNs) often erroneously stuffed in alternateIdentifier for contained items (journal articles, book chapters, ...), are to be shifted into relatedIdentifier instead -->
<xsl:variable name="varRelPidDoi" select="concat(' DOI:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[contains(., 'doi.org/10.')]/concat(lower-case(substring-after(., 'doi.org/')), ':::', @relationType), (//datacite:relatedIdentifier)[contains(., 'info:doi:')]/concat(substring-after(., 'info:doi:'), ':::', @relationType), (//datacite:relatedIdentifier)[@relatedIdentifierType='DOI'][not(contains(., 'doi.org/10.')) and not(contains(., 'info:doi:')) and not(contains(., '/doi/'))]/concat(lower-case(.), ':::', @relationType), (//datacite:relatedIdentifier)[matches(., '.*/doi/.*/10\..*')]/concat(replace(., '.*/doi/.*/(10\..*)$', '$1'), ':::', @relationType) )), ' DOI:::'))"/>
<xsl:variable name="varRelPidHandle" select="concat(' Handle:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[contains(., 'hdl.handle.net/')]/concat(substring-after(., 'hdl.handle.net/'), ':::', @relationType), (//datacite:relatedIdentifier)[contains(., 'info:hdl:')]/concat(substring-after(., 'info:hdl:'), ':::', @relationType), (//datacite:relatedIdentifier)[lower-case(@relatedIdentifierType)='handle'][not(contains(., 'hdl.handle.net/')) and not(contains(., 'info:hdl:'))]/concat(., ':::', @relationType) )), ' Handle:::'))"/>
<xsl:variable name="varRelPidPmid" select="concat(' PMID:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[contains(., '://www.ncbi.nlm.nih.gov/pmc/articles/')]/concat(substring-after(., '://www.ncbi.nlm.nih.gov/pmc/articles/'), ':::', @relationType), (//datacite:relatedIdentifier)[lower-case(@*)='pmc'][not(contains(., 'ncbi.nlm.nih.gov'))]/concat(., ':::', @relationType) )), ' PMID:::'))"/>
<xsl:variable name="varRelPidPmcid" select="concat(' PMCID:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[lower-case(@*)='pmcid'] /concat(., ':::', @relationType) )), ' PMCID:::'))"/>
<xsl:variable name="varRelPidArxiv" select="concat(' arXiv:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[lower-case(@*)='arxiv'] /concat(., ':::', @relationType) )), ' arXiv:::'))"/>
<xsl:variable name="varRelPidWos" select="concat(' WOS:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[lower-case(@*)='wos'][not(starts-with(lower-case(.), 'wos:'))]/concat(., ':::', @relationType), (//datacite:relatedIdentifier)[starts-with(lower-case(.), 'wos:')]/concat(substring-after(lower-case(.), 'wos:'), ':::', @relationType) )), ' WOS:::'))"/>
<xsl:variable name="varRelPidUrl" select="concat(' URL:::', string-join(distinct-values(( (//datacite:relatedIdentifier)[lower-case(@*)='url'] [not(contains(., 'doi.org/10.')) and not(contains(., 'info:doi:')) and not(matches(., '.*/doi/.*/10\..*'))] [not(contains(., 'hdl.handle.net/')) and not(contains(., 'info:hdl:'))] [not(contains(., '://www.ncbi.nlm.nih.gov/pmc/articles/'))] /concat(., ':::', @relationType) )), ' URL:::'))"/>
<xsl:variable name="varRelPid" select="concat($varRelPidDoi[not(. = ' DOI:::')], $varRelPidHandle[not(. = ' Handle:::')], $varRelPidPmid[not(. = ' PMID:::')], $varRelPidPmcid[not(. = ' PMCID:::')], $varRelPidArxiv[not(. = ' arXiv:::')], $varRelPidWos[not(. = ' WOS:::')], $varRelPidUrl[not(. = ' URL:::')])"/><!-- container PIDs --><!-- TODO --><!-- drop oaire resource --><!-- <oaire:resource xmlns="http://namespace.openaire.eu/schema/oaire/"> -->
<record>
<xsl:apply-templates select="//*[local-name() = 'header']"/>
<metadata>
<!-- dc:identifier -->
<datacite:identifier>
<xsl:attribute name="identifierType" select="substring-before(tokenize(normalize-space($varPid), ' ')[1], ':::')"/>
<xsl:value-of select="substring-after(tokenize(normalize-space($varPid), ' ')[1], ':::')"/>
</datacite:identifier>
<!-- dc:title -->
<xsl:if test="//dc:title">
<datacite:titles>
<xsl:for-each select="distinct-values(//dc:title)[string-length(normalize-space(.)) &gt; 0]">
<datacite:title>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:value-of select="."/>
</datacite:title>
</xsl:for-each>
</datacite:titles>
</xsl:if>
<!-- dc:description -->
<xsl:if test="//dc:description">
<datacite:descriptions>
<xsl:for-each select="//dc:description">
<datacite:description>
<xsl:attribute name="descriptionType" select="'Abstract'"/>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:value-of select="."/>
</datacite:description>
</xsl:for-each>
</datacite:descriptions>
</xsl:if>
<!-- dc:subject -->
<xsl:if test="//dc:subject">
<datacite:subjects>
<xsl:for-each select="//dc:subject">
<datacite:subject>
<xsl:value-of select="."/>
</datacite:subject>
</xsl:for-each>
</datacite:subjects>
</xsl:if>
<!-- dc:publisher -->
<xsl:for-each select="distinct-values(//dc:publisher)[string-length(normalize-space(.)) &gt; 0]">
<datacite:publisher>
<xsl:value-of select="normalize-space(.)"/>
</datacite:publisher>
</xsl:for-each>
<!-- dc:subject -->
<xsl:if test="//dc:contributor">
<datacite:contributors>
<xsl:for-each select="//dc:contributor">
<datacite:contributor>
<xsl:value-of select="."/>
</datacite:contributor>
</xsl:for-each>
</datacite:contributors>
</xsl:if>
<!-- dc:source: ISSN
<xsl:for-each select="distinct-values(//dc:source)[string-length(normalize-space(.)) &gt; 0]">
<datacite:publisher>
<xsl:value-of select="normalize-space(.)"/>
</datacite:publisher>
</xsl:for-each>
-->
<!-- dc:format -->
<xsl:if test="//dc:format[string-length(normalize-space(.)) &gt; 0]">
<datacite:formats>
<xsl:for-each select="distinct-values(//dc:format)[string-length(normalize-space(.)) &gt; 0]">
<datacite:format>
<xsl:value-of select="normalize-space(.)"/>
</datacite:format>
</xsl:for-each>
</datacite:formats>
</xsl:if>
<!-- dc:language -->
<xsl:for-each select="distinct-values(//dc:language)[string-length(normalize-space(.)) &gt; 0]">
<datacite:language>
<xsl:value-of select="normalize-space(.)"/>
</datacite:language>
</xsl:for-each>
<oaf:language>
<xsl:value-of select="vocabulary:clean( //*[local-name()='language'], 'dnet:languages')"/>
</oaf:language>
<!-- dc:rights -->
<xsl:if test="(//dc:rights, //oaire:licenseCondition)[string-length(.) &gt; 0 or string-length(@rightsURI) &gt; 0 or string-length(@uri) &gt; 0]">
<datacite:rightsList>
<xsl:for-each select="(//dc:rights | //oaire:licenseCondition)[string-length(.) &gt; 0 or string-length(@rightsURI) &gt; 0 or string-length(@uri) &gt; 0]">
<datacite:rights>
<xsl:value-of select="."/>
</datacite:rights>
</xsl:for-each>
</datacite:rightsList>
</xsl:if>
<!-- fulltext -->
<oaf:fulltext>
<xsl:value-of select="//dc:identifier[starts-with(., 'http') and (ends-with(., 'document') or ends-with(., 'pdf'))]"/>
</oaf:fulltext>
<!-- date -->
<oaf:dateAccepted>
<xsl:value-of select="dateCleaner:dateISO( normalize-space(//dc:date[0]) )"/>
</oaf:dateAccepted>
<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>
</record>
</xsl:template>
<xsl:template name="funding"><!-- funding -->
<xsl:for-each select="//*[local-name()='fundingReference'][./*[local-name()='awardNumber']]">
<xsl:choose><!-- FP7 -->
<xsl:when test="(./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100004963|10.13039/100011199|10.13039/100011102)\s*$')] or (./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000780)$')] and ./*[local-name()='fundingStream'] = ('Framework Programme Seven', 'FP7')) or (./*[local-name()='funderName'] = 'European Commission' and ./*[local-name()='fundingStream'] = ('Framework Programme Seven', 'FP7'))) and ./*[local-name()='awardNumber'][matches(., '.*(^|[^\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:when><!-- H2020 (Horizon 2020 Framework Programme) --><!-- -->
<xsl:when test="(./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100010661)\s*')] or (./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000780)$')] and ./*[local-name()='fundingStream'] = ('Horizon 2020 Framework Programme', 'H2020')) or (./*[local-name()='funderName'] = 'European Commission' and ./*[local-name()='fundingStream'] = ('Horizon 2020 Framework Programme', 'H2020'))) and ./*[local-name()='awardNumber'][matches(., '.*(^|[^\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:when><!-- HE (Horizon Europe Framework Programme) --><!-- -->
<xsl:when test="(./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100018693)\s*')] or (./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000780)$')] and ./*[local-name()='fundingStream'] = ('Horizon Europe Framework Programme', 'HE')) or (./*[local-name()='funderName'] = 'European Commission' and ./*[local-name()='fundingStream'] = ('Horizon Europe Framework Programme', 'HE'))) and ./*[local-name()='awardNumber'][matches(., '.*(^|[^\d])\d\d\d\d\d\d\d\d($|[^\d]).*')]">
<oaf:projectid>
<xsl:value-of select="concat($varHEUROPE, replace(./*[local-name()='awardNumber'], '.*(^|[^\d])(\d\d\d\d\d\d\d\d)($|[^\d]).*', '$2'))"/>
</oaf:projectid>
</xsl:when><!-- AKA -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100002341)\s*$') ] or ./*[local-name()='funderName'][contains(., 'Suomen Akatemia') or contains(., 'Academy of Finland')]">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- ARC -->
<xsl:when test="(./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000923)\s*$')] or ./*[local-name()='funderName'][contains(., 'Australian Research Council')]) and ./*[local-name()='awardNumber'][matches(., '^\d{6}$')]">
<oaf:projectid>
<xsl:value-of select="concat($varAKA, replace(./*[local-name()='awardNumber'], '.*(^\d{6}$).*', '$2'))"/>
</oaf:projectid>
</xsl:when><!-- CONICYT -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100002848)\s*$')] or ./*[local-name()='funderName'][contains(., 'Comisión Nacional de Investigación Científica y Tecnológica') or contains(., 'CONICYT')]">
<oaf:projectid>
<xsl:value-of select="concat($varCONICYT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- DFG -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100001659)\s*$')] or ./*[local-name()='funderName'][contains(., 'Deutsche Forschungsgemeinschaft') or contains(., 'DFG') or contains(., 'Deutsche Forschungsgemeinschaft (DFG)')]">
<oaf:projectid>
<xsl:value-of select="concat($varDFG, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!----><!-- FCT -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100001871)\s*$')] or ./*[local-name()='funderName'][contains(., 'Fundação para a Ciência e a Tecnologia')]">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- FWF -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100002428)\s*$')] or ./*[local-name()='funderName'][contains(., 'Fonds zur Förderung der Wissenschaftlichen Forschung') or contains(., 'Austrian Science Fund')]">
<oaf:projectid>
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- MESTD -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100001871)\s*$')] or ./*[local-name()='funderName'][(contains(., 'Ministarstvo Prosvete, Nauke i Tehnolo') and contains(., 'kog Razvoja')) or contains(., 'MESTD')]">
<oaf:projectid>
<xsl:value-of select="concat($varMESTD, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- MZOS -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100006588)\s*$')] or ./*[local-name()='funderName'][contains(., 'Ministarstvo Znanosti, Obrazovanja i Sporta') or contains(., 'Ministry of Science, Education and Sports')]">
<oaf:projectid>
<xsl:value-of select="concat($varMZOS, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- NHMRC -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000925)\s*$')] or ./*[local-name()='funderName'][contains(., 'National Health and Medical Research Council') or contains(., 'NHMRC')]">
<oaf:projectid>
<xsl:value-of select="concat($varNHMRC, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- NIH -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100000002)\s*$')] or ./*[local-name()='funderName'][contains(., 'National Institutes of Health')]">
<oaf:projectid>
<xsl:value-of select="concat($varNIH, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- NSF -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100000001)\s*$')] or ./*[local-name()='funderName'][contains(., 'National Science Foundation')]">
<oaf:projectid>
<xsl:value-of select="concat($varNSF, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- NWO -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100003246)\s*$')] or ./*[local-name()='funderName'][contains(., 'Netherlands Organisation for Scientific Research') or contains(., 'Nederlandse Organisatie voor Wetenschappelijk Onderzoek')]">
<oaf:projectid>
<xsl:value-of select="concat($varNWO, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- RCUK -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100000690)\s*$')] or ./*[local-name()='funderName'][contains(., 'Research Councils UK') or contains(., 'RCUK')]">
<oaf:projectid>
<xsl:value-of select="concat($varUKRI, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- SFI -->
<xsl:when test="(./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100001602)\s*$')] or ./*[local-name()='funderName'][contains(., 'Science Foundation Ireland')]) and ./*[local-name()='awardNumber'][matches(., '.*([\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:when><!-- SNSF -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100001711)\s*$')] or ./*[local-name()='funderName'][contains(., 'Swiss National Science Foundation') or contains(., 'Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung')]">
<oaf:projectid>
<xsl:value-of select="concat($varSNSF, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- TUBITAK -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/501100004410)\s*$')] or ./*[local-name()='funderName'][contains(., 'Turkish National Science and Research Council') or (contains(., 'Türkiye Bilimsel ve Teknolojik Ara') and contains(., 'rma Kurumu'))]">
<oaf:projectid>
<xsl:value-of select="concat($varTUBITAK, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- UKRI -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100014013)\s*$')] or ./*[local-name()='funderName'][contains(., 'UK Research and Innovation') or contains(., 'UKRI')]">
<oaf:projectid>
<xsl:value-of select="concat($varUKRI, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when><!-- WT -->
<xsl:when test="./*[local-name()='funderIdentifier'][matches(., '.*(doi.org/)?(10.13039/100004440)\s*$')] or ./*[local-name()='funderName'][contains(., 'Wellcome Trust') or . = 'WT']">
<oaf:projectid>
<xsl:value-of select="concat($varWT, ./*[local-name()='awardNumber'])"/>
</oaf:projectid>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>