Skip to content

Instantly share code, notes, and snippets.

@geo-mac
Last active June 15, 2023 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geo-mac/cfff4f84181f4906b580982c7bb2c96a to your computer and use it in GitHub Desktop.
Save geo-mac/cfff4f84181f4906b580982c7bb2c96a to your computer and use it in GitHub Desktop.
MODS-EPrints XSLT serializer, accommodating 'publication states' from Pure with 'Dates, Dates, Dates' extension for EPrints - Strathclyde
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:v3="http://www.loc.gov/mods/v3" xmlns:date="http://exslt.org/dates-and-times" xmlns:xlin="http://www.w3.org/1999/xlink" xmlns:riox="http://docs.rioxx.net/schema/v1.0/rioxxterms/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array" version="1.0" exclude-result-prefixes="v3">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="text()"/>
<xsl:template match="v3:mods">
<eprints>
<eprint>
<!-- Document visibility -->
<xsl:choose>
<xsl:when test="v3:note[@type='publication workflow state' and text()='approved']">
<eprint_status>archive</eprint_status>
</xsl:when>
<xsl:otherwise>
<eprint_status>buffer</eprint_status>
</xsl:otherwise>
</xsl:choose>
<!-- publishing status UKPURE-403 -->
<xsl:choose>
<xsl:when test="v3:note[@type='publicationStatus']='published'">
<ispublished>pub</ispublished>
</xsl:when>
<xsl:when test="v3:note[@type='publicationStatus']='inpress'">
<ispublished>inpress</ispublished>
</xsl:when>
<xsl:when test="v3:note[@type='publicationStatus']='unpublished'">
<ispublished>unpub</ispublished>
</xsl:when>
<xsl:when test="v3:note[@type='publicationStatus']='inprep'">
<ispublished>submitted</ispublished>
</xsl:when>
<xsl:otherwise>
<ispublished>pub</ispublished>
</xsl:otherwise>
</xsl:choose>
<!-- @g3om4c Old publication state data, prior to "Dates, Dates, Dates" <date_type>published</date_type> -->
<source>pure</source>
<!-- Succeeds/replaced by -->
<xsl:for-each select="v3:relatedItem[@type='succeeding']/v3:identifier[starts-with(text(), 'eprints:')]">
<succeeds>
<xsl:value-of select="normalize-space(substring-after(text(), 'eprints:'))"/>
</succeeds>
</xsl:for-each>
<xsl:for-each select="v3:relatedItem[@type='preceding']/v3:identifier[starts-with(text(), 'eprints:')]">
<replacedby>
<xsl:value-of select="normalize-space(substring-after(text(), 'eprints:'))"/>
</replacedby>
</xsl:for-each>
<!-- Title -->
<title>
<xsl:value-of select="v3:titleInfo/v3:title"/>
<xsl:if test="v3:titleInfo/v3:subTitle">
<xsl:text> : </xsl:text>
<xsl:value-of select="v3:titleInfo/v3:subTitle"/>
</xsl:if>
</title>
<!-- @g3om4c New publication state data, following "Dates, Dates, Dates" modifications on EPrints-->
<dates>
<xsl:if test="v3:originInfo/v3:dateIssued">
<item>
<date><xsl:value-of select="v3:originInfo/v3:dateIssued"/></date>
<date_type>published</date_type>
</item>
</xsl:if>
<xsl:if test="v3:originInfo/v3:dateOther[@type='epub']">
<item>
<date><xsl:value-of select="v3:originInfo/v3:dateOther[@type='epub']"/></date>
<date_type>published_online</date_type>
</item>
</xsl:if>
<xsl:if test="v3:originInfo/v3:dateOther[@type='inpress']">
<item>
<date><xsl:value-of select="v3:originInfo/v3:dateOther[@type='inpress']"/></date>
<date_type>accepted</date_type>
</item>
</xsl:if>
<xsl:if test="v3:originInfo/v3:dateOther[@type='submitted']">
<item>
<date><xsl:value-of select="v3:originInfo/v3:dateOther[@type='submitted']"/></date>
<date_type>submitted</date_type>
</item>
</xsl:if>
</dates>
<!-- @g3om4c Old publication state data, prior to "Dates, Dates, Dates"
<date>
<xsl:value-of select="v3:originInfo/v3:dateIssued"/>
</date> -->
<xsl:if test="v3:name[@type='personal']/v3:role/v3:roleTerm[@authority='pure/email']">
<contact_email>
<xsl:value-of select="v3:name[@type='personal']/v3:role/v3:roleTerm[@authority='pure/email']"/>
</contact_email>
</xsl:if>
<!-- Authors -->
<xsl:if test="v3:name[@type='personal' and count(v3:role/v3:roleTerm[@authority='pure/role' and text()='editor'])=0 and count(v3:role/v3:roleTerm[@authority='pure/role' and text()='groupauthor'])=0]">
<creators>
<xsl:for-each select="v3:name[@type='personal' and count(v3:role/v3:roleTerm[@authority='pure/role' and text()='editor'])=0 and count(v3:role/v3:roleTerm[@authority='pure/role' and text()='groupauthor'])=0]">
<item>
<name>
<family>
<xsl:value-of select="v3:namePart[@type='family']"/>
</family>
<given>
<xsl:value-of select="v3:namePart[@type='given']"/>
</given>
</name>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/email']">
<email>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/email']"/>
</email>
</xsl:if>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/employeeId']">
<personid>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/employeeId']"/>
</personid>
</xsl:if>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/personName']">
<pure_preferred_name>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/personName']"/>
</pure_preferred_name>
</xsl:if>
<!-- Modification by @g3om4c to accommodate ORCID -->
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/orcid']">
<orcid>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/orcid']"/>
</orcid>
</xsl:if>
</item>
</xsl:for-each>
</creators>
</xsl:if>
<!-- Editors -->
<xsl:if test="v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role'] = 'editor']">
<editors>
<xsl:for-each select="v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role'] = 'editor']">
<item>
<name>
<family>
<xsl:value-of select="v3:namePart[@type='family']"/>
</family>
<given>
<xsl:value-of select="v3:namePart[@type='given']"/>
</given>
</name>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/email']">
<email>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/email']"/>
</email>
</xsl:if>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/employeeId']">
<personid>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/employeeId']"/>
</personid>
</xsl:if>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/personName']">
<pure_preferred_name>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/personName']"/>
</pure_preferred_name>
</xsl:if>
<xsl:if test="v3:role/v3:roleTerm[@authority='pure/orcid']">
<orcid>
<xsl:value-of select="v3:role/v3:roleTerm[@authority='pure/orcid']"/>
</orcid>
</xsl:if>
</item>
</xsl:for-each>
</editors>
</xsl:if>
<!-- Group Authors -->
<xsl:if test="v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role'] = 'groupauthor']">
<corp_creators>
<xsl:for-each select="v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role'] = 'groupauthor']">
<item>
<xsl:value-of select="v3:namePart[@type='given']"/>
</item>
</xsl:for-each>
</corp_creators>
</xsl:if>
<!-- Organisation associations -->
<xsl:if test="v3:name[@type='corporate']/v3:role/v3:roleTerm[@authority='pure/linkidentifier/eprint']">
<divisions>
<xsl:for-each select="v3:name[@type='corporate']/v3:role/v3:roleTerm[@authority='pure/linkidentifier/eprint']">
<item>
<xsl:value-of select="."/>
</item>
</xsl:for-each>
</divisions>
</xsl:if>
<!-- Peer reviewed -->
<xsl:choose>
<xsl:when test="v3:note[@type='peerreview status' and text()='Peer reviewed']">
<refereed>TRUE</refereed>
</xsl:when>
<!-- UKPURE-2642 -->
<xsl:when test="v3:genre[@type='publicationType' and text() = '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontobookanthology/peerreviewedchapter']">
<refereed>TRUE</refereed>
</xsl:when>
<xsl:otherwise>
<refereed>FALSE</refereed>
</xsl:otherwise>
</xsl:choose>
<!-- Handle structured keywords which are placed in subject/topic -->
<xsl:if test="v3:subject/v3:topic">
<subjects>
<xsl:for-each select="v3:subject/v3:topic">
<xsl:variable name="subject" select="."/>
<xsl:if test="count(../../v3:classification[@displayLabel = $subject])">
<xsl:if test="starts-with(../../v3:classification[@displayLabel = $subject]/text(), '/dk/atira/pure/core/keywords/subjects/')">
<item>
<xsl:call-template name="uppercase">
<xsl:with-param name="uri">
<xsl:call-template name="find-last-token">
<xsl:with-param name="uri" select="../../v3:classification[@displayLabel = $subject]/text()"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</item>
</xsl:if>
</xsl:if>
</xsl:for-each>
</subjects>
</xsl:if>
<!-- Official URL -->
<xsl:if test="v3:location/v3:url[@note='Official URL']">
<xsl:for-each select="v3:location/v3:url[@note='Official URL']">
<official_url>
<xsl:value-of select="."/>
</official_url>
</xsl:for-each>
</xsl:if>
<xsl:if test="count(v3:location/v3:url[@note='Official URL']) = 0">
<xsl:for-each select="v3:identifier[@type='doi']">
<xsl:choose>
<xsl:when test="starts-with(text(), 'https://doi.org/')">
<official_url>
<xsl:value-of select="."/>
</official_url>
</xsl:when>
<xsl:otherwise>
<official_url>
<xsl:value-of select="concat('https://doi.org/', text())"/>
</official_url>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
<!-- Related URLs -->
<xsl:if test="v3:location/v3:url">
<related_url>
<xsl:for-each select="v3:location/v3:url">
<xsl:choose>
<xsl:when test="@note='Official URL'">
<!-- NOP: Official URL is handled above -->
</xsl:when>
<xsl:otherwise>
<item>
<url>
<xsl:value-of select="."/>
</url>
<xsl:choose>
<xsl:when test="@note='Author'">
<type>author</type>
</xsl:when>
<xsl:when test="@note='Department'">
<type>department</type>
</xsl:when>
<xsl:when test="@note='Event'">
<type>event</type>
</xsl:when>
<xsl:when test="@note='Journal or Publication'">
<type>journal</type>
</xsl:when>
<xsl:when test="@note='Organisation'">
<type>org</type>
</xsl:when>
<xsl:when test="@note='Publisher'">
<type>pub</type>
</xsl:when>
<xsl:when test="@note='Related Item'">
<type>related</type>
</xsl:when>
<xsl:when test="@note='Strathprints record'">
<type>strathprints</type>
</xsl:when>
<xsl:when test="@note='Scopus publication'">
<type>scopuspub</type>
</xsl:when>
<xsl:when test="@note='Scopus citations'">
<type>scopuscite</type>
</xsl:when>
<xsl:when test="@note='Reprint'">
<type>reprint</type>
</xsl:when>
<xsl:otherwise>
<type/>
</xsl:otherwise>
</xsl:choose>
</item>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</related_url>
</xsl:if>
<tr_ut>
<xsl:value-of select="normalize-space(substring-after(v3:identifier[@type='local' and starts-with(text(), 'WOS:')], 'WOS:'))"/>
</tr_ut>
<xsl:apply-templates/>
</eprint>
</eprints>
</xsl:template>
<xsl:template match="v3:note[@type='referencetext']">
<referencetext>
<xsl:value-of select="."/>
</referencetext>
</xsl:template>
<xsl:template match="v3:abstract[@type='content']">
<abstract>
<xsl:value-of select="."/>
</abstract>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host']/v3:part/v3:detail[@type='volume']/v3:number">
<volume>
<xsl:value-of select="."/>
</volume>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host']/v3:part/v3:detail[@type='issue']/v3:number">
<number>
<xsl:value-of select="."/>
</number>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host']/v3:part/v3:detail[@type='citation']/v3:caption">
<pagerange>
<xsl:value-of select="."/>
</pagerange>
</xsl:template>
<xsl:template match="v3:physicalDescription/v3:extent">
<pages>
<xsl:value-of select="."/>
</pages>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host']/v3:identifier[@type='issn']">
<issn>
<xsl:value-of select="."/>
</issn>
</xsl:template>
<!-- Modification by @g3om4c to accommodate article_number -->
<xsl:template match="v3:relatedItem[@type='host']/v3:part/v3:detail[@type='articleNumber']/v3:number">
<article_number>
<xsl:value-of select="."/>
</article_number>
</xsl:template>
<xsl:template match="v3:originInfo/v3:place/v3:placeTerm">
<place_of_pub>
<xsl:value-of select="."/>
</place_of_pub>
</xsl:template>
<xsl:template match="v3:originInfo[local-name(..)='mods']/v3:publisher">
<publisher>
<xsl:value-of select="."/>
</publisher>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='series']/v3:titleInfo/v3:title">
<series>
<xsl:value-of select="."/>
</series>
</xsl:template>
<xsl:template match="v3:identifier[@type='isbn' and local-name(..)='mods']">
<isbn>
<xsl:value-of select="."/>
</isbn>
</xsl:template>
<xsl:template match="v3:identifier[@type='doi' and local-name(..)='mods']">
<id_number>
<xsl:value-of select="normalize-space(substring-after(text(), 'https://doi.org/'))"/>
</id_number>
</xsl:template>
<xsl:template match="v3:part[local-name(..)='mods']/v3:detail[@type='volume']/v3:number">
<volume>
<xsl:value-of select="."/>
</volume>
</xsl:template>
<xsl:template match="v3:part[local-name(..)='mods']/v3:detail[@type='edition']/v3:number">
<number>
<xsl:value-of select="."/>
</number>
</xsl:template>
<!-- Subjects matches to free keywords -->
<xsl:template match="v3:subject">
<xsl:choose>
<xsl:when test="@xlin:type != ''"/>
<!-- We only want non-qualified topics -->
<xsl:otherwise>
<keywords>
<xsl:for-each select="v3:topic">
<xsl:if test="position() != 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</keywords>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="v3:note">
<xsl:choose>
<xsl:when test="@type != ''"/>
<!-- We only want non-qualified notes -->
<xsl:otherwise>
<note>
<xsl:value-of select="."/>
</note>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host' and @xlin:role='conference']/v3:titleInfo/v3:title">
<event_title>
<xsl:value-of select="."/>
</event_title>
</xsl:template>
<xsl:template match="v3:relatedItem[@type='host' and @xlin:role='conference']/v3:location/v3:physicalLocation">
<event_location>
<xsl:value-of select="."/>
</event_location>
</xsl:template>
<xsl:template match="v3:relatedItem[@xlin:role='media']/v3:physicalDescription/v3:form">
<output_media>
<xsl:value-of select="."/>
</output_media>
</xsl:template>
<!-- metadata visibility STRATHCLYDEPURE-247 -->
<xsl:template match="v3:note[@type='metadata visibility']">
<xsl:choose>
<xsl:when test=".='FREE'">
<metadata_visibility>show</metadata_visibility>
</xsl:when>
<xsl:when test=".='CAMPUS'">
<metadata_visibility>no_search</metadata_visibility>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Conference start/end -->
<xsl:template match="v3:relatedItem[@type='host' and @xlin:role='conference']/v3:part">
<xsl:choose>
<xsl:when test="v3:date[@point='start'] and v3:date[@point='end']">
<event_dates>
<xsl:value-of select="v3:date[@point='start']"/> -
<xsl:value-of select="v3:date[@point='end']"/>
</event_dates>
</xsl:when>
<xsl:when test="v3:date[@point='start']">
<event_dates>
<xsl:value-of select="v3:date[@point='start']"/>
</event_dates>
</xsl:when>
<xsl:when test="v3:date[@point='end']">
<event_dates>
<xsl:value-of select="v3:date[@point='end']"/>
</event_dates>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="v3:genre[@type='publicationType']">
<!-- Type token used for matching for sub types -->
<xsl:variable name="typeToken">
<xsl:call-template name="find-last-token">
<xsl:with-param name="uri" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<!-- Other contribution -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/othercontribution/')">
<!-- STRATHCLYDEPURE-239 -->
<type>other</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Contribution to Journal -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontojournal/')">
<xsl:choose>
<!-- Specified in STRATHCLYDEPURE-235 not exactly this issue, but sais that Book/Film/Article Review for specialist contribution should map to
review, so assume Book/Film/Article Review for contribution to journal also should -->
<xsl:when test="$typeToken = 'book'">
<type>review</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<xsl:otherwise>
<type>article</type>
<xsl:call-template name="journalMatch"/>
</xsl:otherwise>
</xsl:choose>
<!-- UKPURE-2305 -->
<articleNumber>
<xsl:value-of select="//v3:part/v3:detail[@type='articleNumber']/v3:number"/>
</articleNumber>
</xsl:when>
<!-- Contribution to Periodical -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontoperiodical/')">
<xsl:choose>
<!-- Specified in STRATHCLYDEPURE-235 -->
<xsl:when test="$typeToken = 'book'">
<type>review</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<xsl:otherwise>
<type>article</type>
<xsl:call-template name="journalMatch"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Patent -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/patent/')">
<type>patent</type>
<xsl:call-template name="patentType"/>
</xsl:when>
<!-- Contribution to Conference -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontoconference/')">
<type>conference_item</type>
<xsl:call-template name="conferenceItemType">
<xsl:with-param name="uriToken" select="$typeToken"/>
</xsl:call-template>
</xsl:when>
<!-- Book Anthology -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/bookanthology/')">
<xsl:choose>
<!-- Specified in STRATHCLYDEPURE-234 -->
<xsl:when test="$typeToken='other' or $typeToken='commissioned'">
<type>report</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<xsl:otherwise>
<type>book</type>
<xsl:call-template name="bookTitleMatch"/>
</xsl:otherwise>
</xsl:choose>
<!-- UKPURE-2305 -->
<xsl:call-template name="editionMatch"/>
</xsl:when>
<!-- Contribution to Book Anthology -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontobookanthology/')">
<type>book_section</type>
<xsl:call-template name="bookTitleMatch"/>
<!--UKPURE-2305 -->
<xsl:call-template name="editionMatch"/>
</xsl:when>
<!-- Non-textual -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/nontextual/')">
<xsl:choose>
<!-- An artist's artefact or work product. -->
<xsl:when test="$typeToken='artefact'">
<type>artefact</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Exhibition -->
<xsl:when test="$typeToken='exhibition'">
<type>exhibition</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Composition -->
<xsl:when test="$typeToken='composition'">
<type>composition</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Performance -->
<xsl:when test="$typeToken='performance'">
<type>performance</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- STRATHCLYDEPURE-236 -->
<xsl:when test="$typeToken='digitalorvisualproducts'">
<type>other</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Data Set -->
<xsl:when test="$typeToken='database'">
<type>dataset</type>
<xsl:call-template name="journalMatch"/>
</xsl:when>
<!-- Other non-textual -->
<xsl:otherwise>
<type>other</type>
<xsl:call-template name="journalMatch"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Working Paper -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/workingpaper/')">
<type>monograph</type>
<xsl:call-template name="monographType">
<xsl:with-param name="uriToken" select="$typeToken"/>
</xsl:call-template>
</xsl:when>
<!-- Thesis -->
<xsl:when test="starts-with(text(), '/dk/atira/pure/researchoutput/researchoutputtypes/thesis/')">
<!-- Thesis, specified in STRATHCLYDEPURE-238, STRATHCLYDEPURE-237 -->
<type>thesis</type>
<xsl:call-template name="thesisType">
<xsl:with-param name="uriToken" select="$typeToken"/>
</xsl:call-template>
</xsl:when>
<!--
Other types
-->
<xsl:otherwise>
<type>other</type>
<xsl:call-template name="journalMatch"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="journalMatch">
<xsl:if test="../v3:relatedItem[@type='host']/v3:titleInfo/v3:title">
<publication>
<xsl:value-of select="../v3:relatedItem[@type='host']/v3:titleInfo/v3:title"/>
</publication>
</xsl:if>
</xsl:template>
<xsl:template name="bookTitleMatch">
<xsl:if test="../v3:relatedItem[@type='host']/v3:titleInfo/v3:title">
<book_title>
<xsl:value-of select="../v3:relatedItem[@type='host']/v3:titleInfo/v3:title"/>
</book_title>
</xsl:if>
</xsl:template>
<xsl:template name="editionMatch">
<edition>
<xsl:value-of select="//v3:part/v3:detail[@type='issue']/v3:number"/>
</edition>
</xsl:template>
<xsl:template name="monographType">
<xsl:param name="uriToken"/>
<xsl:choose>
<xsl:when test="$uriToken='casestudy'">
<monograph_type>case_study</monograph_type>
</xsl:when>
<xsl:when test="$uriToken='guideormanual'">
<monograph_type>guide</monograph_type>
</xsl:when>
<xsl:when test="$uriToken='workingpaper'">
<monograph_type>working_paper</monograph_type>
</xsl:when>
<xsl:when test="$uriToken='discussionpaper'">
<monograph_type>discussion_paper</monograph_type>
</xsl:when>
<xsl:otherwise>
<monograph_type>other</monograph_type>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="bookTitleMatch"/>
</xsl:template>
<xsl:template name="thesisType">
<xsl:param name="uriToken"/>
<xsl:choose>
<xsl:when test="$uriToken='master'">
<thesis_type>masters</thesis_type>
</xsl:when>
<xsl:when test="$uriToken='doc'">
<thesis_type>phd</thesis_type>
</xsl:when>
<xsl:otherwise>
<thesis_type>other</thesis_type>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="journalMatch"/>
<institution>
<xsl:value-of select="../v3:note[@type='institution']"/>
</institution>
</xsl:template>
<xsl:template name="conferenceItemType">
<xsl:param name="uriToken"/>
<xsl:choose>
<xsl:when test="$uriToken='keynote'">
<pres_type>keynote</pres_type>
</xsl:when>
<xsl:when test="$uriToken='paper' or $uriToken='proceeding'">
<pres_type>paper</pres_type>
</xsl:when>
<xsl:when test="$uriToken='poster'">
<pres_type>poster</pres_type>
</xsl:when>
<xsl:when test="$uriToken='speech'">
<pres_type>speech</pres_type>
</xsl:when>
<xsl:otherwise>
<pres_type>other</pres_type>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="../v3:relatedItem[@type='host' and @xlin:role='conference']/v3:part/v3:text[@xlin:role='pure/conferencetype']='Conference'">
<event_type>conference</event_type>
</xsl:when>
<xsl:when test="../v3:relatedItem[@type='host' and @xlin:role='conference']/v3:part/v3:text[@xlin:role='pure/conferencetype']='Workshop'">
<event_type>workshop</event_type>
</xsl:when>
<xsl:otherwise>
<event_type>other</event_type>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="journalMatch"/>
</xsl:template>
<xsl:template name="patentType">
<xsl:if test="../v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role']='inventor']">
<patent_applicant>
<xsl:value-of select="../v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role']='inventor']/v3:namePart[@type='family']"/>,
<xsl:value-of select="../v3:name[@type='personal' and v3:role/v3:roleTerm[@authority='pure/role']='inventor']/v3:namePart[@type='given']"/>
</patent_applicant>
</xsl:if>
<xsl:choose>
<xsl:when test="../v3:subject[@xlin:type='ipc']/v3:topic">
<id_number>
<xsl:value-of select="../v3:subject[@xlin:type='ipc']/v3:topic"/>
</id_number>
</xsl:when>
<xsl:when test="../v3:identifier[@type='patent_number']">
<id_number>
<xsl:value-of select="../v3:identifier[@type='patent_number']"/>
</id_number>
</xsl:when>
</xsl:choose>
<xsl:call-template name="journalMatch"/>
</xsl:template>
<xsl:template name="find-last-token">
<xsl:param name="uri"/>
<xsl:choose>
<xsl:when test="contains($uri,'/')">
<xsl:call-template name="find-last-token">
<xsl:with-param name="uri" select="substring-after($uri,'/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$uri"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="uppercase">
<xsl:param name="uri"/>
<xsl:value-of select="translate($uri, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</xsl:template>
<!-- Modification by @g3om4c to accommodate RIOXX elements for OpenAIRE compliance via CORE -->
<xsl:key name="openaire" match="v3:extension/*[not(self::riox:funder)]" use="generate-id(preceding-sibling::riox:funder[1])"/>
<xsl:template match="v3:extension">
<rioxx2_project_input>
<xsl:for-each select="riox:funder">
<item>
<project>
<xsl:value-of select="key('openaire', generate-id())[self::riox:projectid]"/>
</project>
<funder_name>
<xsl:value-of select="."/>
</funder_name>
</item>
</xsl:for-each>
</rioxx2_project_input>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment