Commit 01df9c73 authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

Expand test to include a second XSLT transformation for oai_dc metadataPrefix

parent 299c9305
......@@ -88,16 +88,22 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
@Test
public void getSinglePublication() throws IOException {
String xsltString = IOUtils.toString(
Map<String, String> map = new HashMap<>();
String xMetaDissPlusXsltString = IOUtils.toString(
getClass().
getClassLoader().
getResourceAsStream("xslt/africaspectrum-xmetadissplus-2-xmlbundle.xslt"), StandardCharsets.UTF_8);
//LOG.info(xMetaDissPlusxsltString);
map.put("xMetaDissPlus", xMetaDissPlusXsltString);
LOG.info(xsltString);
String oaiDcXsltString = IOUtils.toString(
getClass().
getClassLoader().
getResourceAsStream("xslt/africaspectrum-oai_dc-2-xmlbundle.xslt"), StandardCharsets.UTF_8);
map.put("oai_dc", oaiDcXsltString);
Map<String, String> map = new HashMap<>();
map.put("xMetaDissPlus", xsltString);
//XsltTransformerOaiPmhBundlesStreamSource bss = new XsltTransformerOaiPmhBundlesStreamSource("https://journals.sub.uni-hamburg.de/giga/afsp/oai/", map);
XsltTransformerOaiPmhBundlesStreamSource bss =
new XsltTransformerOaiPmhBundlesStreamSource(
......@@ -109,6 +115,8 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.review", "2") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title", "de", "Buchbesprechung: Manfred Schulz (Hrsg.): Entwicklungsträger in der DR Kongo. Entwicklungen in Politik, Wirtschaft, Religion, Zivilgesellschaft und Kultur (2007)") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title.alternative", "en", "Review: Manfred Schulz (ed.): Entwicklungsträger in der DR Kongo. Entwicklungen in Politik, Wirtschaft, Religion, Zivilgesellschaft und Kultur (2007)") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issuetopic", "New Nationalism and Xenophobia in Africa") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.pageinfo", "125-127") ) );
bundle = bss.getBundle("oai:hup.sub.uni-hamburg.de.giga:article/122");
......@@ -116,6 +124,7 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.review", "1") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title", "en", "The Ethiopian Second Republic and the Fragile “Social Contract”") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title.alternative", "de", "Die 2. Republik in Äthiopien und der “fragile Gesellschaftsvertrag“") ) );
assertTrue( metadata.stream().noneMatch(m -> m.getKey().equals("dc.source.issuetopic")) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.pageinfo", "3-28") ) );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:xoai="http://www.lyncode.com/xoai"
xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
xmlns:cc="http://www.d-nb.de/standards/cc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:pc="http://www.d-nb.de/standards/pc/"
xmlns:urn="http://www.d-nb.de/standards/urn/"
xmlns:hdl="http://www.d-nb.de/standards/hdl/"
xmlns:doi="http://www.d-nb.de/standards/doi/"
xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
xmlns:ddb="http://www.d-nb.de/standards/ddb/"
xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:zoai="http://git.gesis.org/dda/zoai">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- <xsl:copy-of select="."/> -->
<!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
<!-- override default template -->
<xsl:template match="*" />
<xsl:template match="/">
<xsl:element name="bundle">
<xsl:element name="metadata">
<xsl:apply-templates select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc" />
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="dc:source">
<!--
dc.source.pageinfo and dc.source.issuetopic may or may not exist in oai_dc's dc:source ...
see e.g. http://journals.sub.uni-hamburg.de/giga/afsp/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:hup.sub.uni-hamburg.de.giga:article/29
see e.g. http://journals.sub.uni-hamburg.de/giga/afsp/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:hup.sub.uni-hamburg.de.giga:article/990
-->
<!-- dc:source may contain an issue topic ... if it exists, it is between ': ' and ';' -->
<xsl:variable name="issuetopic" select="substring-before(substring-after(., ': '), ';')" />
<!-- <xsl:message terminate="no">issuetopic=<xsl:value-of select="$issuetopic"/></xsl:message> -->
<xsl:if test="$issuetopic != ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.issuetopic'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="$issuetopic"/>
</xsl:call-template>
</xsl:if>
<!-- dc:source may contain page information ... if it exists, it is after the last '; ' occurrence -->
<xsl:variable name="pageinfo" select="tokenize(text(),'; ')[last()]" />
<!-- <xsl:message terminate="no">pageinfo=<xsl:value-of select="$pageinfo"/></xsl:message> -->
<xsl:if test="$pageinfo != ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.pageinfo'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="$pageinfo"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="new-metadatum">
<xsl:param name="key" />
<xsl:param name="language" />
<xsl:param name="value" />
<xsl:element name="metadatum">
<xsl:element name="key">
<xsl:value-of select="$key" />
</xsl:element>
<xsl:if test="$language != ''">
<xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage($language)" />
<xsl:element name="language">
<xsl:value-of select="$sanitizedLanguage" />
</xsl:element>
</xsl:if>
<xsl:element name="value">
<xsl:value-of select="$value" />
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:function name="zoai:sanitizeLanguage">
<xsl:param name="inputLanguage" />
<xsl:choose>
<xsl:when test="$inputLanguage = 'ger'">
<xsl:value-of select="'de'" />
</xsl:when>
<xsl:when test="$inputLanguage = 'eng'">
<xsl:value-of select="'en'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$inputLanguage" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment