Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/test_metadata_article_Datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def test_similarity(self):

transform = ET.XSLT(xslt) # is it a reserved word
newdom = transform(dom)
print(newdom)

real_string = ET.tostring(newdom, pretty_print=True, encoding='utf8').decode()
# test if result is parsable
reference = ET.parse(r'test/data/articles/Test_Reference-Datacite.xml')
print(reference)

expected_string = ET.tostring(reference, pretty_print=True, encoding='utf8').decode()
diff = main.diff_texts(expected_string, real_string, {
'ratio_mode': 'fast', # is that for latency
Expand Down
114 changes: 78 additions & 36 deletions xslt/articles/xslt-article-Datacite.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -96,43 +96,85 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or
</xsl:template>

<!-- Template for processing authors -->
<xsl:template match="authors">
<creator>
<creatorName nameType="Personal">
<xsl:value-of select="name"/>
</creatorName>
<givenName>
<xsl:value-of select="substring-before(name, ',')"/>
</givenName>
<familyName>
<xsl:value-of select="substring-after(name, ', ')"/>
</familyName>
<nameIdentifier schemeURI="https://zbmath.org/" nameIdentifierScheme="zbMATH Author Code">
<xsl:value-of select="codes"/>
</nameIdentifier>
</creator>
</xsl:template>
<xsl:template match="authors">
<creator>
<creatorName nameType="Personal">
<xsl:choose>
<xsl:when test="normalize-space(name) = '' or name = 'None' or name = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(name)"/>
</xsl:otherwise>
</xsl:choose>
</creatorName>

<givenName>
<xsl:choose>
<xsl:when test="normalize-space(name) = '' or name = 'None' or name = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(substring-before(name, ','))"/>
</xsl:otherwise>
</xsl:choose>
</givenName>

<familyName>
<xsl:choose>
<xsl:when test="normalize-space(name) = '' or name = 'None' or name = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(substring-after(name, ', '))"/>
</xsl:otherwise>
</xsl:choose>
</familyName>

<nameIdentifier schemeURI="https://zbmath.org/" nameIdentifierScheme="zbMATH Author Code">
<xsl:choose>
<xsl:when test="normalize-space(codes) = '' or codes = 'None' or codes = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(codes)"/>
</xsl:otherwise>
</xsl:choose>
</nameIdentifier>
</creator>
</xsl:template>


<!-- Template for processing titles -->
<xsl:template match="title">
<!-- Transform titles into structured titles -->
<titles>
<title xml:lang="en">
<xsl:value-of select="title"/>
</title>
</titles>
</xsl:template>
<!-- Template for processing publisher -->
<xsl:template match="publisher">
<publisher xml:lang="en">
<xsl:value-of select="."/>
</publisher>
</xsl:template>
<!-- Template for processing publication year -->
<xsl:template match="year">
<publicationYear>
<xsl:value-of select="."/>
</publicationYear>
</xsl:template>
<xsl:template match="title">
<titles>
<title xml:lang="en">
<xsl:choose>
<xsl:when test="normalize-space(.) = '' or . = 'None' or . = 'none'">:unkn</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(.)"/>
</xsl:otherwise>
</xsl:choose>
</title>
</titles>
</xsl:template>


<xsl:template match="publisher">
<publisher xml:lang="en">
<xsl:choose>
<xsl:when test="normalize-space(.) = '' or . = 'None' or . = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</publisher>
</xsl:template>

<xsl:template match="year">
<publicationYear>
<xsl:choose>
<xsl:when test="normalize-space(.) = '' or . = 'None' or . = 'none'">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</publicationYear>
</xsl:template>


<!-- Template for processing the language of the document -->
<xsl:template match="languages">
<xsl:if test="normalize-space(.) != '' and . != 'None'and . != 'none'">
Expand Down