Translate underscores to dashes in xml:lang attr for DIM2DataCite.xsl

Modified the DataCite crosswalk to ensure that the xml:lang attribute translates any underscores in the value of @lang to dashes. This change aligns the attribute formatting with standard language code conventions.
This commit is contained in:
Kim Shepherd
2024-09-03 17:13:01 +02:00
parent 74bb24b953
commit a898afd5ac

View File

@@ -25,6 +25,10 @@
to register DOIs anymore. Please follow and reuse the examples to register DOIs anymore. Please follow and reuse the examples
included in this file. For more information on the DataCite included in this file. For more information on the DataCite
Schema, see https://schema.datacite.org. --> Schema, see https://schema.datacite.org. -->
<!-- Note regarding language codes: xml:lang regional language codes require a hyphen, whereas many
repositories use underscores when storing these language codes (e.g. en_GB, de_CH).
This template translates all underscores to hyphens when selecting value of @lang in an attribute
so the output will be e.g. xml:lang="en-GB", xml:lang="de-CH". -->
<!-- We need the prefix to determine DOIs that were minted by ourself. --> <!-- We need the prefix to determine DOIs that were minted by ourself. -->
<xsl:param name="prefix">10.5072/dspace-</xsl:param> <xsl:param name="prefix">10.5072/dspace-</xsl:param>
@@ -362,20 +366,20 @@
<!-- DataCite (3) :: Title --> <!-- DataCite (3) :: Title -->
<xsl:template match="dspace:field[@mdschema='dc' and @element='title']"> <xsl:template match="dspace:field[@mdschema='dc' and @element='title']">
<xsl:element name="title"> <xsl:element name="title">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:if test="@qualifier='alternative'"> <xsl:if test="@qualifier='alternative'">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:attribute name="titleType">AlternativeTitle</xsl:attribute> <xsl:attribute name="titleType">AlternativeTitle</xsl:attribute>
</xsl:if> </xsl:if>
<!-- DSpace does include niehter a dc.title.subtitle nor a <!-- DSpace doesn't include a dc.title.subtitle nor a
dc.title.translated. If necessary, please create those in the dc.title.translated. If necessary, please create those in the
metadata field registry. --> metadata field registry. -->
<xsl:if test="@qualifier='subtitle'"> <xsl:if test="@qualifier='subtitle'">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:attribute name="titleType">Subtitle</xsl:attribute> <xsl:attribute name="titleType">Subtitle</xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="@qualifier='translated'"> <xsl:if test="@qualifier='translated'">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:attribute name="titleType">TranslatedTitle</xsl:attribute> <xsl:attribute name="titleType">TranslatedTitle</xsl:attribute>
</xsl:if> </xsl:if>
<xsl:value-of select="." /> <xsl:value-of select="." />
@@ -394,7 +398,7 @@
--> -->
<xsl:template match="//dspace:field[@mdschema='dc' and @element='subject']"> <xsl:template match="//dspace:field[@mdschema='dc' and @element='subject']">
<xsl:element name="subject"> <xsl:element name="subject">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:if test="@qualifier"> <xsl:if test="@qualifier">
<xsl:attribute name="subjectScheme"><xsl:value-of select="@qualifier" /></xsl:attribute> <xsl:attribute name="subjectScheme"><xsl:value-of select="@qualifier" /></xsl:attribute>
</xsl:if> </xsl:if>
@@ -626,7 +630,7 @@
--> -->
<xsl:template match="//dspace:field[@mdschema='dc' and @element='description' and (@qualifier='abstract' or @qualifier='tableofcontents' or not(@qualifier))]"> <xsl:template match="//dspace:field[@mdschema='dc' and @element='description' and (@qualifier='abstract' or @qualifier='tableofcontents' or not(@qualifier))]">
<xsl:element name="description"> <xsl:element name="description">
<xsl:attribute name="xml:lang"><xsl:value-of select="@lang" /></xsl:attribute> <xsl:attribute name="xml:lang"><xsl:value-of select="translate(@lang, '_', '-')" /></xsl:attribute>
<xsl:attribute name="descriptionType"> <xsl:attribute name="descriptionType">
<xsl:choose> <xsl:choose>
<xsl:when test="@qualifier='abstract'">Abstract</xsl:when> <xsl:when test="@qualifier='abstract'">Abstract</xsl:when>