115693: Pass doi metadatafield with xsl parameters

(cherry picked from commit 9e11e1f9ae)
This commit is contained in:
Kristof De Langhe
2024-07-19 13:42:09 +02:00
committed by github-actions[bot]
parent d240a16b05
commit c1be5f8e4e
3 changed files with 23 additions and 11 deletions

View File

@@ -70,7 +70,6 @@ public class DOIIdentifierProvider extends FilteredIdentifierProvider {
static final char SLASH = '/';
// Metadata field name elements
// Warning: If this metadata field is changed for whatever reason, DIM2DataCite.xsl's template needs to reflect this
// TODO: move these to MetadataSchema or some such?
public static final String MD_SCHEMA = "dc";
public static final String DOI_ELEMENT = "identifier";

View File

@@ -7,6 +7,10 @@
*/
package org.dspace.identifier.doi;
import static org.dspace.identifier.DOIIdentifierProvider.DOI_ELEMENT;
import static org.dspace.identifier.DOIIdentifierProvider.DOI_QUALIFIER;
import static org.dspace.identifier.DOIIdentifierProvider.MD_SCHEMA;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -386,6 +390,10 @@ public class DataCiteConnector
parameters.put("hostinginstitution",
configurationService.getProperty(CFG_HOSTINGINSTITUTION));
}
parameters.put("mdSchema", MD_SCHEMA);
parameters.put("mdElement", DOI_ELEMENT);
// Pass an empty string for qualifier if the metadata field doesn't have any
parameters.put("mdQualifier", DOI_QUALIFIER);
Element root = null;
try {

View File

@@ -36,6 +36,10 @@
<xsl:param name="hostinginstitution"><xsl:value-of select="$publisher" /></xsl:param>
<!-- Please take a look into the DataCite schema documentation if you want to know how to use these elements.
http://schema.datacite.org -->
<!-- Metadata-field to retrieve DOI from items -->
<xsl:param name="mdSchema">dc</xsl:param>
<xsl:param name="mdElement">identifier</xsl:param>
<xsl:param name="mdQualifier">uri</xsl:param>
<xsl:output method="xml" indent="yes" encoding="utf-8" />
@@ -333,16 +337,17 @@
company as well. We have to ensure to use URIs of our prefix
as primary identifiers only.
-->
<!-- Warning: If the metadata field changes for whatever reason, DOIIdentifierProvider needs to reflect this -->
<xsl:template match="dspace:field[@mdschema='dc' and @element='identifier' and @qualifier='uri' and (contains(., $prefix))]">
<identifier identifierType="DOI">
<xsl:if test="starts-with(string(text()), 'https://doi.org/')">
<xsl:value-of select="substring(., 17)"/>
</xsl:if>
<xsl:if test="starts-with(string(text()), 'http://dx.doi.org/')">
<xsl:value-of select="substring(., 19)"/>
</xsl:if>
</identifier>
<xsl:template match="dspace:field[@mdschema=$mdSchema and @element=$mdElement and (contains(., $prefix))]">
<xsl:if test="(($mdQualifier and $mdQualifier != '') and @qualifier=$mdQualifier) or ((not($mdQualifier) or $mdQualifier = '') and not(@qualifier))">
<identifier identifierType="DOI">
<xsl:if test="starts-with(string(text()), 'https://doi.org/')">
<xsl:value-of select="substring(., 17)"/>
</xsl:if>
<xsl:if test="starts-with(string(text()), 'http://dx.doi.org/')">
<xsl:value-of select="substring(., 19)"/>
</xsl:if>
</identifier>
</xsl:if>
</xsl:template>
<!-- DataCite (2) :: Creator -->