Skip to content
Closed
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
3 changes: 3 additions & 0 deletions test/data/articles/Test_Reference-Datacite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<relatedIdentifier relatedIdentifierType="URL" relationType="IsCitedBy">https://zbmath.org/6587992</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="URL" relationType="IsCitedBy">https://zbmath.org/195021</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="DOI" relationType="Cites" resourceTypeGeneral="JournalArticle">10.4007/annals.2014.179.3.7</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="ARXIV"
relationType="IsPartOf"
resourceTypeGeneral="JournalArticle">1311.4600</relatedIdentifier>
</relatedIdentifiers>
<rightsList>
<rights xml:lang="en" schemeURI="https://api.zbmath.org/v1/" rightsIdentifierScheme="zbMATH" rightsIdentifier="CC-BY-SA 4.0" rightsURI="https://creativecommons.org/licenses/by-sa/4.0/">
Expand Down
1 change: 1 addition & 0 deletions test/data/articles/invalid_chr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@
<author_codes>trotter.william-t-jun</author_codes>
<document_id>3902698</document_id>
<msc>05C55</msc>
<msc>06A07</msc>
<prefix>Zbl</prefix>
<series_id>0</series_id>
<year>1985</year>
Expand Down
152 changes: 73 additions & 79 deletions test/data/software/Datacite-software-reference.xml

Large diffs are not rendered by default.

86 changes: 38 additions & 48 deletions test/data/software/OpenAire-software-reference.xml

Large diffs are not rendered by default.

230 changes: 115 additions & 115 deletions test/data/software/plain_with_references.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/oai_connect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class PlainXmlTest(unittest.TestCase):
def test_similarity(self):
self.assertEqual("1.3.0", oai_connection.get_version())
self.assertEqual("1.5.1", oai_connection.get_version())


if __name__ == '__main__':
Expand Down
23 changes: 22 additions & 1 deletion test/test_extract_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,28 @@ def test_software():
'https://api.zbmath.org/v1/software/12',
headers=headers)
real_tags = extract_tags(r.json()['result'])
assert real_tags == ['60', '65', '78', '82']
assert real_tags == ['(optics),',
'2010:',
'60J70',
'65C50',
'78A05',
'78A45',
'82D25',
'Appl.',
'Crystals',
'Diffraction,',
'Geometric',
'MSC',
'Other',
'computational',
'diffusion',
'in',
'of',
'optics,',
'probability,',
'problems',
'scattering',
'theory,']

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion test/test_zbMATH_API_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_api_version(url):
class TestAPIVersion(unittest.TestCase):
def test_api_version_matches(self):
url = "https://api.zbmath.org/openapi.json"
expected_version = "1.7.0"
expected_version = "1.7.1"
actual_version = get_api_version(url)
self.assertEqual(actual_version, expected_version,
f"Expected API version {expected_version}, but got {actual_version}")
Expand Down
124 changes: 89 additions & 35 deletions xslt/articles/xslt-article-Datacite.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,26 @@ Made by Shiraz Malla Mohamad member of zbmath Team-->
<xsl:apply-templates select="root/editorial_contributions/text"/>
</descriptions>
</xsl:if>
<xsl:apply-templates select="root/title"/>
<xsl:if test="root/title[
normalize-space(.) != ''
and . != 'None'
and . != 'none'
and not(contains(., 'zbMATH Open Web Interface contents unavailable due to conflicting licenses'))
]">
<xsl:apply-templates select="root/title"/>
</xsl:if>


<xsl:if test="not(root/title[
normalize-space(.) != ''
and . != 'None'
and . != 'none'
and not(contains(., 'zbMATH Open Web Interface contents unavailable due to conflicting licenses'))
])">
<titles>
<title>:unav</title>
</titles>
</xsl:if>
<xsl:apply-templates select="root/source/series/publisher"/>
<xsl:apply-templates select="root/year"/>
<xsl:if test="root/msc[normalize-space(.) != '' and normalize-space(.) != 'None' and normalize-space(.) != 'none' and not(contains(., 'zbMATH Open Web Interface contents unavailable due to conflicting licenses'))]
Expand All @@ -54,7 +73,8 @@ Made by Shiraz Malla Mohamad member of zbmath Team-->
not(contains(., 'zbMATH Open Web Interface contents unavailable due to conflicting licenses'))])
]">
<relatedIdentifiers>
<xsl:apply-templates select="//references"/>
<xsl:apply-templates select="//references"/>
<xsl:apply-templates select="root/links" mode="relatedIdentifiers"/>
</relatedIdentifiers>
</xsl:if>
<!-- Wrap the rights element inside a rightsList element -->
Expand All @@ -75,24 +95,33 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or
</resource>
</xsl:template>
<!-- Template for processing identifiers -->
<xsl:template match="root/links">
<xsl:choose>
<!-- Process the first 'links' node that has a 'doi' identifier -->
<xsl:when test="self::links[type = 'doi' and normalize-space(identifier) != ''][1]">
<identifier identifierType="DOI">
<xsl:value-of select="identifier"/>
</identifier>
</xsl:when>
<!-- If no 'doi' identifier is present, consider 'arxiv' -->
<xsl:when
test="self::links[type = 'arxiv' and normalize-space(identifier) != ''][1] and not(preceding-sibling::links[type = 'doi' and normalize-space(identifier) != ''])">
<identifier identifierType="ARXIV">
<xsl:value-of select="identifier"/>
</identifier>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Template for processing the rest of the identifiers of our Metadata and considered as alternative identifiers-->
<xsl:template match="root/links">
<xsl:variable name="allDOIs" select="//links[type = 'doi' and normalize-space(identifier) != '']" />
<xsl:variable name="firstDOI" select="$allDOIs[1]" />
<xsl:variable name="allArXiv" select="//links[type = 'arxiv' and normalize-space(identifier) != '']" />
<xsl:variable name="firstArXiv" select="$allArXiv[1]" />


<xsl:choose>

<xsl:when test="self::node()[generate-id() = generate-id($firstDOI)]">
<identifier identifierType="DOI">
<xsl:value-of select="identifier"/>
</identifier>
</xsl:when>


<xsl:when test="not($allDOIs) and self::node()[generate-id() = generate-id($firstArXiv)]">
<identifier identifierType="ARXIV">
<xsl:value-of select="identifier"/>
</identifier>
</xsl:when>
</xsl:choose>


<xsl:apply-templates select="root/links" mode="relatedIdentifiers"/>
</xsl:template>

<xsl:template match="identifier">
<xsl:if test="normalize-space(.) != '' and . != 'None' and . != 'none'">
<alternateIdentifier alternateIdentifierType="zbMATH Identifier">
Expand Down Expand Up @@ -159,17 +188,24 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or

<!-- Template for processing titles -->
<xsl:template match="title">
<titles>
<title xml:lang="en">
<xsl:choose>
<xsl:when test="normalize-space(.) = '' or normalize-space(.) = 'None' or normalize-space(.) = 'none' or contains(., 'zbMATH Open Web Interface contents unavailable due to conflicting licenses')">:unav</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(.)"/>
</xsl:otherwise>
</xsl:choose>
</title>
</titles>
</xsl:template>
<titles>
<title xml:lang="en">
<xsl:choose>
<!-- Check the *inner* title (your actual title text) -->
<xsl:when test="not(title) or
normalize-space(title) = '' or
title = 'None' or
title = 'none' or
contains(title, 'zbMATH Open Web Interface contents unavailable due to conflicting licenses')">
:unav
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(title)"/>
</xsl:otherwise>
</xsl:choose>
</title>
</titles>
</xsl:template>


<xsl:template match="publisher">
Expand Down Expand Up @@ -349,7 +385,7 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or

<xsl:template match="references">
<xsl:choose>
<!-- If DOI is valid, use DOI -->

<xsl:when test="normalize-space(doi) != ''
and doi != 'None'
and doi != 'none'
Expand All @@ -359,7 +395,7 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or
</relatedIdentifier>
</xsl:when>

<!-- Otherwise, check zbmath/document_id -->

<xsl:when test="zbmath/document_id[normalize-space()
and . != 'None'
and . != 'none'
Expand All @@ -371,9 +407,27 @@ Content generated by zbMATH Open, such as reviews, classifications, software, or
</xsl:choose>
</xsl:template>

<xsl:template match="root/links" mode="relatedIdentifiers">
<xsl:variable name="allDOIs" select="//links[type = 'doi' and normalize-space(identifier) != '']" />
<xsl:variable name="firstDOI" select="$allDOIs[1]" />
<xsl:variable name="allArXiv" select="//links[type = 'arxiv' and normalize-space(identifier) != '']" />
<xsl:variable name="firstArXiv" select="$allArXiv[1]" />

<xsl:if test="type = 'doi' and normalize-space(identifier) != '' and not(generate-id() = generate-id($firstDOI))">
<relatedIdentifier relatedIdentifierType="DOI" relationType="IsPartOf" resourceTypeGeneral="JournalArticle">
<xsl:value-of select="identifier"/>
</relatedIdentifier>
</xsl:if>

<xsl:if test="type = 'arxiv' and normalize-space(identifier) != '' and
(not(generate-id() = generate-id($firstArXiv)) or $allDOIs)">
<relatedIdentifier relatedIdentifierType="ARXIV" relationType="IsPartOf" resourceTypeGeneral="JournalArticle">
<xsl:value-of select="identifier"/>
</relatedIdentifier>
</xsl:if>
</xsl:template>


<!-- Template to match references and transform into relatedItems
each reference has its own relatedItem node and all of its values goes under this node -->
<xsl:template match="references" mode="relatedItems">
<xsl:if test="(normalize-space(doi) != ''
and doi != 'None'
Expand Down