Created
August 28, 2017 08:15
-
-
Save rivaldi8/0ca7986a2889406c9c7b2a14cbcd95c6 to your computer and use it in GitHub Desktop.
XSLT to convert OAI XML with DIM metadata to Crossref submission XML for DOI registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Description: Converts metadata from DSpace Intermediat Format (DIM) into | |
metadata following the Crossref Schema version 4.3.6. | |
--> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:oai="http://www.openarchives.org/OAI/2.0/" | |
xmlns:dspace="http://www.dspace.org/xmlns/dspace/dim" | |
xmlns:uuid="java:java.util.UUID" | |
xmlns:date="java:java.lang.System" | |
xmlns="http://www.crossref.org/schema/4.3.6" | |
version="2.0"> | |
<xsl:output method="xml" indent="yes" encoding="utf-8" /> | |
<!-- Don't copy everything by default! --> | |
<xsl:template match="@* | text()" /> | |
<xsl:template match="//oai:ListRecords"> | |
<doi_batch version="4.3.6" xmlns="http://www.crossref.org/schema/4.3.6" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.crossref.org/schema/4.3.6 http://www.crossref.org/schemas/crossref4.3.6.xsd"> | |
<head> | |
<doi_batch_id><xsl:value-of select="uuid:randomUUID()"/></doi_batch_id> | |
<timestamp><xsl:value-of select="date:currentTimeMillis()"/></timestamp> | |
<depositor> | |
<depositor_name>UdL</depositor_name> | |
<email_address>alexandre.magaz@udl.cat</email_address> | |
</depositor> | |
<registrant>CrossRef</registrant> | |
</head> | |
<body> | |
<journal> | |
<journal_metadata> | |
<full_title>Imago temporis: medium Aevum</full_title> | |
<issn>1888-3931</issn> | |
</journal_metadata> | |
<xsl:apply-templates /> | |
</journal> | |
</body> | |
</doi_batch> | |
</xsl:template> | |
<xsl:template match="//dspace:dim"> | |
<journal_article> | |
<!-- | |
Title | |
http://www.crossref.org/help/schema_doc/4.3.6/common4_3_5_xsd.html#http___www.crossref.org_relations.xsd_titles | |
--> | |
<titles> | |
<xsl:apply-templates select="dspace:field[@mdschema='dc' and @element='title']" /> | |
</titles> | |
<!-- | |
Publication date | |
http://www.crossref.org/help/schema_doc/4.3.6/common4_3_5_xsd.html#http___www.crossref.org_relations.xsd_publication_date | |
--> | |
<publication_date> | |
<year> | |
<xsl:choose> | |
<xsl:when test="dspace:field[@mdschema='dc' and @element='date' and @qualifier='issued']"> | |
<xsl:value-of select="substring(dspace:field[@mdschema='dc' and @element='date' and @qualifier='issued'], 1, 4)" /> | |
</xsl:when> | |
<xsl:when test="dspace:field[@mdschema='dc' and @element='date' and @qualifier='available']"> | |
<xsl:value-of select="substring(dspace:field[@mdschema='dc' and @element='date' and @qualifier='issued'], 1, 4)" /> | |
</xsl:when> | |
<xsl:when test="dspace:field[@mdschema='dc' and @element='date']"> | |
<xsl:value-of select="substring(dspace:field[@mdschema='dc' and @element='date'], 1, 4)" /> | |
</xsl:when> | |
<xsl:otherwise>0000</xsl:otherwise> | |
</xsl:choose> | |
</year> | |
</publication_date> | |
<!-- | |
DOI | |
http://www.crossref.org/help/schema_doc/4.3.6/common4_3_5_xsd.html#http___www.crossref.org_relations.xsd_doi_data | |
--> | |
<xsl:apply-templates select="dspace:field[@mdschema='dc' and @element='identifier' and starts-with(., 'https://doi.org/')]" /> | |
</journal_article> | |
</xsl:template> | |
<!-- DOI --> | |
<xsl:template match="dspace:field[@mdschema='dc' and @element='identifier' and starts-with(., 'https://doi.org/')]"> | |
<doi_data> | |
<doi><xsl:value-of select="substring(., 17)"/></doi> | |
<resource> | |
<xsl:value-of select="../dspace:field[@mdschema='dc' | |
and @element='identifier' | |
and @qualifier='uri' | |
and starts-with(., 'http://hdl.handle.net/')]"/> | |
</resource> | |
</doi_data> | |
</xsl:template> | |
<!-- Title --> | |
<xsl:template match="dspace:field[@mdschema='dc' and @element='title']"> | |
<xsl:element name="title"> | |
<xsl:value-of select="." /> | |
</xsl:element> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
set
to select the collection/community andfrom
to select items published from that date.articles.crossref.xml
:journal_metadata/full_title
.journal_metadata/issn
.