Commit 47b18fb0 authored by Fischer, Tim's avatar Fischer, Tim
Browse files

transformation for iqas

parent 87a660ca
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xpath-default-namespace="http://www.openarchives.org/OAI/2.0/"
xmlns:cc="http://www.d-nb.de/standards/cc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:ddb="http://www.d-nb.de/standards/ddb/"
xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
xmlns:doi="http://www.d-nb.de/standards/doi/"
xmlns:hdl="http://www.d-nb.de/standards/hdl/"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:nlm="http://dtd.nlm.nih.gov/publishing/2.3"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:pc="http://www.d-nb.de/standards/pc/"
xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
xmlns:urn="http://www.d-nb.de/standards/urn/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
xmlns:xoai="http://www.lyncode.com/xoai"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:zoai="http://git.gesis.org/dda/zoai">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<!-- <xsl:copy-of select="."/> -->
<!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of
select='text()' /> </xsl:message> -->
<!-- override default template -->
<xsl:template match="*" />
<xsl:template match="/">
<xsl:element name="bundle">
<xsl:element name="metadata">
<xsl:apply-templates
select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc" />
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template
match="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.source.journal'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'2245'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.type.stock'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'article'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.type.document'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'32'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.description.pubstatus'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'1'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.publisher'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'Arnold Bergstraesser Institute'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.publisher.country'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'DEU'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'ssoar.urn.registration'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'false'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.identifier.issn'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'2566-6878'" />
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'internal.status'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="'formal und inhaltlich fertig erschlossen'" />
</xsl:call-template>
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="dc:language">
<xsl:variable name="sanitizedLanguage"
select="zoai:sanitizeLanguage( text() )" />
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.language'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="$sanitizedLanguage" />
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:creator">
<xsl:choose>
<xsl:when test="contains(text(), ';')">
<xsl:variable name="tokenizedAuthors"
select="tokenize(text(),';')" />
<xsl:for-each select="$tokenizedAuthors">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.contributor.author'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="normalize-space(.)" />
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.contributor.author'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="text()" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="dc:description">
<xsl:variable name="sanitizedLanguage"
select="zoai:sanitizeLanguage(@xml:lang)" />
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.description.abstract'" />
<xsl:with-param name="language"
select="$sanitizedLanguage" />
<xsl:with-param name="value"
select="normalize-space(replace(text(),'[»«]','&quot;'))" />
</xsl:call-template>
<xsl:variable name="maybeUrn"
select="zoai:extractUrnFromFqsAbstract(text() )" />
<xsl:if test="$maybeUrn != ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.identifier.urn'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="$maybeUrn" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="dc:rights">
<xsl:if test="matches(., 'https://creativecommons.org/licenses/by-nc-nd/4.0')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.rights.licence'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="'20'" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="dc:source[@xml:lang='en-US']">
<xsl:variable name="pageinfo"
select="tokenize( text(),'; ' )[last()]" />
<xsl:if
test="$pageinfo != '' and matches($pageinfo, '^\d+(-\d+)?')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.source.pageinfo'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="$pageinfo" />
</xsl:call-template>
</xsl:if>
<xsl:variable name="issued"
select="substring-before(substring-after(text(),'('),')')" />
<xsl:if
test="$issued != ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.date.issued'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="$issued" />
</xsl:call-template>
</xsl:if>
<xsl:variable name="issuetopic"
select="substring-before(substring-after(text(),': '),';')" />
<xsl:if
test="$issuetopic != ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.source.issuetopic'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="$issuetopic" />
</xsl:call-template>
</xsl:if>
<xsl:variable name="issue"
select="substring-before(substring-after(text(),'No.'),'(')" />
<xsl:if test="$issue != '' and matches ($issue, '\d+')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.issue'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="normalize-space($issue)" />
</xsl:call-template>
</xsl:if>
<xsl:variable name="volume"
select="substring-before(substring-after(text(),'Vol. '),' ')" />
<xsl:if test="$volume != '' and matches ($volume, '\d+')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.source.volume'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="normalize-space($volume)" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template
match="dc:identifier[matches(text(), '^10\..*')]">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.identifier.doi'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value"
select="concat('https://doi.org/', text())" />
</xsl:call-template>
</xsl:template>
<xsl:template
match="dc:identifier[matches(text(), 'https://hasp.ub.uni-heidelberg.de/journals/iqas/article/view')]">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.identifier.url'" />
<xsl:with-param name="language" select="''" />
<xsl:with-param name="value" select="text()" />
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:title">
<xsl:variable name="sanitizedLanguage"
select="zoai:sanitizeLanguage( @xml:lang )" />
<xsl:variable name="sanitizedMainLanguage"
select="zoai:sanitizeLanguage( /oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:language )" />
<xsl:choose>
<xsl:when test="$sanitizedLanguage = $sanitizedMainLanguage">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.title'" />
<xsl:with-param name="language"
select="$sanitizedLanguage" />
<xsl:with-param name="value"
select="replace(text(), '\.$','')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key"
select="'dc.title.alternative'" />
<xsl:with-param name="language"
select="$sanitizedLanguage" />
<xsl:with-param name="value"
select="replace(text(), '\.$','')" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="new-metadatum">
<xsl:param name="key" />
<xsl:param name="language" />
<xsl:param name="value" />
<xsl:element name="metadatum">
<xsl:element name="key">
<xsl:value-of select="$key" />
</xsl:element>
<xsl:if test="$language != ''">
<xsl:variable name="sanitizedLanguage"
select="zoai:sanitizeLanguage($language)" />
<xsl:element name="language">
<xsl:value-of select="$sanitizedLanguage" />
</xsl:element>
</xsl:if>
<xsl:element name="value">
<xsl:value-of select="$value" />
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:function name="zoai:sanitizeLanguage">
<xsl:param name="inputLanguage" />
<xsl:choose>
<xsl:when
test="$inputLanguage = 'ger' or $inputLanguage = 'DE' or $inputLanguage = 'de-DE' or $inputLanguage = 'deu'">
<xsl:value-of select="'de'" />
</xsl:when>
<xsl:when
test="$inputLanguage = 'eng' or $inputLanguage = 'EN' or $inputLanguage = 'en-US' or $inputLanguage = 'en-GB'">
<xsl:value-of select="'en'" />
</xsl:when>
<xsl:when
test="$inputLanguage = 'pol' or $inputLanguage = 'PL' or $inputLanguage = 'pl-PL'">
<xsl:value-of select="'pl'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$inputLanguage" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="zoai:extractUrnFromFqsAbstract">
<xsl:param name="rawString" />
<xsl:analyze-string select="$rawString"
regex=".*(urn:nbn:de:.*)$">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)" />
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:function>
</xsl:stylesheet>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment