bugfix: doi-registration: Refactor XSLT and Vue components for improved data validation and conditional rendering
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s

- Updated doi_datacite.xslt to include conditional checks for empty values in creators, titles, subjects, contributors, dates, rights, sizes, formats, descriptions, and geoLocations to ensure only non-empty elements are rendered.
- Enhanced the handling of TitleAbstract and TitleAbstractAdditional templates to only output descriptions if the Value attribute is not empty.
- Modified the Doi.vue component to clean up the import statements and commented out unused warning display code for clarity.
This commit is contained in:
Kaimbacher 2025-12-04 17:01:13 +01:00
commit b16a1ba3f0
4 changed files with 201 additions and 158 deletions

View file

@ -62,15 +62,19 @@
</xsl:choose>
<!--<datacite:creator>-->
<creators>
<xsl:apply-templates select="PersonAuthor" mode="oai_datacite">
<xsl:sort select="@SortOrder"/>
</xsl:apply-templates>
</creators>
<titles>
<xsl:apply-templates select="TitleMain" mode="oai_datacite" />
<xsl:apply-templates select="TitleAdditional" mode="oai_datacite" />
</titles>
<xsl:if test="PersonAuthor[normalize-space(concat(@FirstName, @LastName)) != '']">
<creators>
<xsl:apply-templates select="PersonAuthor" mode="oai_datacite">
<xsl:sort select="@SortOrder"/>
</xsl:apply-templates>
</creators>
</xsl:if>
<xsl:if test="TitleMain[normalize-space(@Value) != ''] or TitleAdditional[normalize-space(@Value) != '']">
<titles>
<xsl:apply-templates select="TitleMain" mode="oai_datacite" />
<xsl:apply-templates select="TitleAdditional" mode="oai_datacite" />
</titles>
</xsl:if>
<publisher>
<!-- <xsl:value-of select="@PublisherName" /> -->
<xsl:value-of select="@CreatingCorporation" />
@ -78,22 +82,26 @@
<publicationYear>
<xsl:value-of select="ServerDatePublished/@Year" />
</publicationYear>
<subjects>
<xsl:apply-templates select="Subject" mode="oai_datacite" />
</subjects>
<xsl:if test="Subject[normalize-space(@Value) != '']">
<subjects>
<xsl:apply-templates select="Subject" mode="oai_datacite" />
</subjects>
</xsl:if>
<language>
<xsl:value-of select="@Language" />
</language>
<xsl:if test="PersonContributor">
<xsl:if test="PersonContributor[normalize-space(concat(@FirstName, @LastName)) != '']">
<contributors>
<xsl:apply-templates select="PersonContributor" mode="oai_datacite">
<xsl:sort select="@SortOrder"/>
</xsl:apply-templates>
</contributors>
</xsl:if>
<dates>
<xsl:call-template name="RdrDate2" />
</dates>
<xsl:if test="(EmbargoDate and ($unixTimestamp &lt; EmbargoDate/@UnixTimestamp)) or CreatedAt">
<dates>
<xsl:call-template name="RdrDate2" />
</dates>
</xsl:if>
<version>
<xsl:choose>
<xsl:when test="@Version">
@ -109,42 +117,46 @@
<!-- <xsl:value-of select="@Type" /> -->
</resourceType>
<alternateIdentifiers>
<xsl:call-template name="AlternateIdentifier" />
</alternateIdentifiers>
<xsl:if test="normalize-space(@landingpage) != ''">
<alternateIdentifiers>
<xsl:call-template name="AlternateIdentifier" />
</alternateIdentifiers>
</xsl:if>
<xsl:if test="Reference">
<xsl:if test="Reference[normalize-space(@Type) != '' and normalize-space(@Relation) != '']">
<relatedIdentifiers>
<xsl:apply-templates select="Reference" mode="oai_datacite" />
</relatedIdentifiers>
</xsl:if>
<rightsList>
<xsl:apply-templates select="Licence" mode="oai_datacite" />
</rightsList>
<sizes>
<size>
<xsl:value-of select="count(File)" />
<xsl:text> datasets</xsl:text>
</size>
</sizes>
<formats>
<xsl:apply-templates select="File/@MimeType" mode="oai_datacite" />
</formats>
<descriptions>
<xsl:apply-templates select="TitleAbstract" mode="oai_datacite" />
<xsl:apply-templates select="TitleAbstractAdditional" mode="oai_datacite" />
</descriptions>
<geoLocations>
<xsl:apply-templates select="Coverage" mode="oai_datacite" />
<!-- <geoLocation>
<geoLocationBox>
<westBoundLongitude>6.58987</westBoundLongitude>
<eastBoundLongitude>6.83639</eastBoundLongitude>
<southBoundLatitude>50.16</southBoundLatitude>
<northBoundLatitude>50.18691</northBoundLatitude>
</geoLocationBox>
</geoLocation> -->
</geoLocations>
<xsl:if test="Licence[normalize-space(@Name) != '' or normalize-space(@Url) != '']">
<rightsList>
<xsl:apply-templates select="Licence" mode="oai_datacite" />
</rightsList>
</xsl:if>
<xsl:if test="File">
<sizes>
<size>
<xsl:value-of select="count(File)" />
<xsl:text> datasets</xsl:text>
</size>
</sizes>
</xsl:if>
<xsl:if test="File[normalize-space(@MimeType) != '']">
<formats>
<xsl:apply-templates select="File/@MimeType" mode="oai_datacite" />
</formats>
</xsl:if>
<xsl:if test="TitleAbstract[normalize-space(@Value) != ''] or TitleAbstractAdditional[normalize-space(@Value) != '']">
<descriptions>
<xsl:apply-templates select="TitleAbstract" mode="oai_datacite" />
<xsl:apply-templates select="TitleAbstractAdditional" mode="oai_datacite" />
</descriptions>
</xsl:if>
<xsl:if test="Coverage[normalize-space(@XMin) != '' and normalize-space(@XMax) != '' and normalize-space(@YMin) != '' and normalize-space(@YMax) != '']">
<geoLocations>
<xsl:apply-templates select="Coverage" mode="oai_datacite" />
</geoLocations>
</xsl:if>
</resource>
</xsl:template>
@ -176,54 +188,54 @@
<xsl:template match="Coverage" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<geoLocation>
<geoLocationBox>
<westBoundLongitude>
<xsl:value-of select="@XMin" />
</westBoundLongitude>
<eastBoundLongitude>
<xsl:value-of select="@XMax" />
</eastBoundLongitude>
<southBoundLatitude>
<xsl:value-of select="@YMin" />
</southBoundLatitude>
<northBoundLatitude>
<xsl:value-of select="@YMax" />
</northBoundLatitude>
</geoLocationBox>
</geoLocation>
<xsl:if test="normalize-space(@XMin) != '' and normalize-space(@XMax) != '' and normalize-space(@YMin) != '' and normalize-space(@YMax) != ''">
<geoLocation>
<geoLocationBox>
<westBoundLongitude><xsl:value-of select="@XMin" /></westBoundLongitude>
<eastBoundLongitude><xsl:value-of select="@XMax" /></eastBoundLongitude>
<southBoundLatitude><xsl:value-of select="@YMin" /></southBoundLatitude>
<northBoundLatitude><xsl:value-of select="@YMax" /></northBoundLatitude>
</geoLocationBox>
</geoLocation>
</xsl:if>
</xsl:template>
<!-- TitleAbstract template -->
<xsl:template match="TitleAbstract" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<!-- <xsl:value-of select="@Type" /> -->
<xsl:text>Abstract</xsl:text>
<xsl:if test="normalize-space(@Value) != ''">
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<xsl:text>Abstract</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
</xsl:if>
</xsl:template>
<!-- TitleAbstractAdditional template -->
<xsl:template match="TitleAbstractAdditional" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<xsl:call-template name="CamelCaseWord">
<xsl:with-param name="text" select="@Type" />
</xsl:call-template>
<xsl:if test="normalize-space(@Value) != ''">
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<xsl:call-template name="CamelCaseWord">
<xsl:with-param name="text" select="@Type" />
</xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
</xsl:if>
</xsl:template>
<xsl:template name="CamelCaseWord">
@ -256,6 +268,7 @@
<xsl:template match="TitleMain" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''">
<title>
<xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang">
@ -269,9 +282,12 @@
</xsl:if>
<xsl:value-of select="@Value" />
</title>
</xsl:if>
</xsl:template>
<xsl:template match="TitleAdditional" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''">
<title>
<xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang">
@ -294,61 +310,70 @@
</xsl:choose>
<xsl:value-of select="@Value" />
</title>
</xsl:if>
</xsl:template>
<xsl:template match="Subject" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<subject>
<xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</subject>
<xsl:if test="normalize-space(@Value) != ''">
<subject>
<xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</subject>
</xsl:if>
</xsl:template>
<xsl:template name="AlternateIdentifier" match="AlternateIdentifier" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<alternateIdentifier>
<xsl:attribute name="alternateIdentifierType">
<xsl:text>url</xsl:text>
</xsl:attribute>
<!-- <xsl:variable name="identifier" select="concat($repURL, '/dataset/', @Id)" /> -->
<xsl:value-of select="@landingpage" />
</alternateIdentifier>
<xsl:if test="normalize-space(@landingpage) != ''">
<alternateIdentifier>
<xsl:attribute name="alternateIdentifierType">
<xsl:text>url</xsl:text>
</xsl:attribute>
<xsl:value-of select="@landingpage" />
</alternateIdentifier>
</xsl:if>
</xsl:template>
<xsl:template match="Reference" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<relatedIdentifier>
<xsl:attribute name="relatedIdentifierType">
<xsl:value-of select="@Type" />
</xsl:attribute>
<xsl:attribute name="relationType">
<xsl:value-of select="@Relation" />
</xsl:attribute>
<xsl:value-of select="@Value" />
</relatedIdentifier>
<xsl:if test="normalize-space(@Type) != '' and normalize-space(@Relation) != ''">
<relatedIdentifier>
<xsl:attribute name="relatedIdentifierType">
<xsl:value-of select="@Type" />
</xsl:attribute>
<xsl:attribute name="relationType">
<xsl:value-of select="@Relation" />
</xsl:attribute>
<xsl:value-of select="@Value" />
</relatedIdentifier>
</xsl:if>
</xsl:template>
<!-- PersonContributor template -->
<xsl:template match="PersonContributor" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<contributor>
<xsl:if test="@ContributorType != ''">
<xsl:attribute name="contributorType">
<xsl:value-of select="@ContributorType" />
</xsl:attribute>
</xsl:if>
<contributorName>
<!-- <xsl:if test="@NameType != ''">
<xsl:attribute name="nameType">
<xsl:value-of select="@NameType" />
</xsl:attribute>
</xsl:if> -->
<xsl:value-of select="concat(@FirstName, ' ',@LastName)" />
</contributorName>
</contributor>
<xsl:if test="normalize-space(concat(@FirstName, @LastName)) != ''">
<contributor>
<xsl:if test="@ContributorType != ''">
<xsl:attribute name="contributorType">
<xsl:value-of select="@ContributorType" />
</xsl:attribute>
</xsl:if>
<contributorName>
<!-- <xsl:if test="@NameType != ''">
<xsl:attribute name="nameType">
<xsl:value-of select="@NameType" />
</xsl:attribute>
</xsl:if> -->
<xsl:value-of select="concat(@FirstName, ' ', @LastName)" />
</contributorName>
</contributor>
</xsl:if>
</xsl:template>
<xsl:template match="PersonAuthor" mode="oai_datacite"
@ -403,9 +428,11 @@
<xsl:template match="File/@MimeType" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<format>
<xsl:value-of select="." />
</format>
<xsl:if test="normalize-space(.) != ''">
<format>
<xsl:value-of select="." />
</format>
</xsl:if>
</xsl:template>
<xsl:template match="Licence" mode="oai_datacite"