Commit 29e94a85 authored by Steinberg, Jan's avatar Steinberg, Jan

tatup transformation including test case

parent 107a71c7
......@@ -1882,6 +1882,77 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
}
@Test
public void getSinglePublicationTatup() throws IOException {
Map<String, String> map = new HashMap<>();
// String oaiMarcXsltString = IOUtils.toString(
// getClass().
// getClassLoader().
// getResourceAsStream("xslt/hjk-oai_marc-2-xmlbundle.xslt"), StandardCharsets.UTF_8);
// map.put("oai_marc", oaiMarcXsltString);
//
String oaiDcXsltString = IOUtils.toString(
getClass().
getClassLoader().
getResourceAsStream("xslt/tatup-oai_dc-2-xmlbundle.xslt"), StandardCharsets.UTF_8);
map.put("oai_dc", oaiDcXsltString);
XsltTransformerOaiPmhBundlesStreamSource bss = new XsltTransformerOaiPmhBundlesStreamSource("https://www.tatup.de/index.php/tatup/oai", map);
Bundle bundle = bss.getBundle("oai:TATuP:article/22");
LOG.info("{}", bundle);
Set<Metadatum> metadata = bundle.getMetadata();
metadata.stream().map(Object::toString).forEach(LOG::info);
assertTrue( metadata.contains( new SimpleMetadatum("dc.type.stock", "article") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.type.document", "32") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.journal", "1661") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.pubstatus", "1") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Weber, Karsten") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Kleine, Nadine") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Pallas, Frank") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Ulbricht, Max-R.") ) );
assertEquals(4, metadata.stream().filter(m -> m.getKey().equals("dc.contributor.author") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.review", "1") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.description.review") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.date.issued", "2017") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.abstract", "de", "Wenn BürgerInnen aktiv am Datengewinnungsprozess als zentralem Baustein empirisch ausgerichteter wissenschaftlicher Projekte teilhaben, kann dies als Beitrag zu einer offenen und bürgernahen Wissenschaft angesehen werden. Eine solche Teilhabe kann durch die Bereitstellung von technischen Werkzeugen erheblich erleichtert werden. Daher sollen Participatory Sensing als Bereitstellung von günstigen Sensoren zur Messung von Umweltparametern sowie Wearable Technologies zur Aufnahme von quantifizierten Vitaldaten und physiologischen Zuständen vorgestellt werden. Konzeptionell kann die Bereitstellung von Daten, die mit diesen Werkzeugen erhoben wurden, als Allmende verstanden werden – mit allen damit verbundenen Chancen und Risiken. Nach der Beschreibung von Beispielen aus den Bereichen von Participatory Sensing und Wearable Technologies werden zu erwartende Herausforderungen identifiziert und technisch-organisatorische Ansätze zu deren Lösung skizziert.") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.abstract", "en", "If citizens actively participate in the process of collecting empirical data, as a key element of empirically oriented scientific projects, this can be seen as a contribution to an open and citizen-oriented science. Such participation can be supported by providing technical tools. The paper therefore presents examples of participatory sensing as the provision of affordable sensors for measuring environmental parameters as well as wearable technologies for recording quantified vital data and physiological states. Conceptually, the provision of data collected with these tools can be understood as a commons – with all opportunities and risks associated with such goods. After describing examples of participatory sensing and wearable technologies, the authors identify potential challenges and outline technical and organizational approaches to solve them.") ) );
assertEquals(2, metadata.stream().filter(m -> m.getKey().equals("dc.description.abstract") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.issn", "2567-8833") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.url", "https://www.tatup.de/index.php/tatup/article/view/22") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.identifier.url") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.language", "de") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issue", "1-2") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issue") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.volume", "26") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.volume") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.rights.licence", "16") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issuetopic", "Open Science – zwischen Hype und Disruption") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issuetopic") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.pageinfo", "25-30") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.pageinfo") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title.alternative", "en", "Participatory sensing and wearable technologies as tools to support citizen and open science") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.title.alternative") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.title", "de", "Technik zur Unterstützung von Citizen Science und Open Science") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.title") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.doi", "https://doi.org/10.14512/tatup.26.1-2.25") ) );
assertTrue( metadata.contains( new SimpleMetadatum("internal.dda.reference", "https://www.tatup.de/index.php/tatup/oai@@oai:TATuP:article/22") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.publisher.country", "DEU") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.classoz", "10900") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.classoz", "10900") ) );
assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.ddc", "300") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.ddc", "300") ) );
assertTrue( metadata.contains( new SimpleMetadatum("internal.status", "formal und inhaltlich fertig erschlossen") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "participatory sensing") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "wearable technology") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "citizen science") ) );
Set<InputStream> fileSet = bundle.getContents();
assertEquals( 2, fileSet.size());
}
@Test
public void iterateThroughFqsPublications() throws IOException {
Map<String, String> map = new HashMap<>();
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
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:ddb="http://www.d-nb.de/standards/ddb/"
xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
xmlns:doi="http://www.d-nb.de/standards/doi/"
xmlns:hdl="http://www.d-nb.de/standards/hdl/"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:nlm="http://dtd.nlm.nih.gov/publishing/2.3"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:pc="http://www.d-nb.de/standards/pc/"
xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
xmlns:urn="http://www.d-nb.de/standards/urn/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
xmlns:xoai="http://www.lyncode.com/xoai"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
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:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.type.stock'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'article'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.type.document'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'32'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.journal'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'1661'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.description.pubstatus'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'1'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.publisher.country'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'DEU'"/>
</xsl:call-template>
<!-- <xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'ssoar.urn.registration'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'false'"/>
</xsl:call-template>-->
<xsl:choose>
<xsl:when test="matches(//oai:setSpec, 'Special') or matches(//oai:setSpec, 'Research')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.description.review'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'1'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.description.review'"/>
<xsl:with-param name="language" select="//setSpec/text()"/>
<xsl:with-param name="value" select="'2'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.identifier.issn'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'2567-8833'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'internal.identifier.ddc'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'300'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.subject.ddc'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'300'"/>
</xsl:call-template>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'internal.status'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'formal und inhaltlich fertig erschlossen'"/>
</xsl:call-template>
<xsl:variable name="issuetopicDE" select="substring-before(tokenize(dc:source[@xml:lang='de-DE']/text(), ': ')[last()], ';')" />
<xsl:variable name="issuetopicEN" select="substring-before(tokenize(dc:source[@xml:lang='en-US']/text(), ': ')[last()], ';')" />
<xsl:choose>
<xsl:when test="$issuetopicDE = $issuetopicEN">
<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="$issuetopicEN"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<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="concat($issuetopicEN, ' / ', $issuetopicDE)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!--xsl:apply-templates select="dc:type[@xml:lang='en-US']" /-->
<xsl:apply-templates select="dc:title" />
<xsl:apply-templates select="dc:description[@xml:lang='de-DE']" />
<xsl:apply-templates select="dc:description[@xml:lang='en-US']" />
<xsl:apply-templates select="dc:language" />
<xsl:apply-templates select="dc:source" />
<xsl:apply-templates select="dc:identifier[matches(text(), '^10\..*')]" />
<xsl:apply-templates select="dc:identifier[matches(text(), '^urn.*')]" />
<!--xsl:apply-templates select="dc:type[@xml:lang='en-US']" /-->
<xsl:apply-templates select="dc:identifier[matches(text(), 'tatup.article.view')]" />
<xsl:apply-templates select="dc:creator" />
<xsl:apply-templates select="dc:date" />
<xsl:apply-templates select="dc:rights" />
<xsl:apply-templates select="dc:subject" />
</xsl:template>
<xsl:template match="dc:subject">
<xsl:choose>
<xsl:when test="not(matches(text(),'open science|open access'))">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.subject.other'"/>
<xsl:with-param name="language" select="'en'"/>
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="dc:rights">
<xsl:choose>
<xsl:when test="contains(text(),'/by/')">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.rights.licence'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="'16'"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="dc:date">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.date.issued'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="substring(text(),1,4)"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:creator">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.contributor.author'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:identifier[matches(text(), 'tatup.article.view')]">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.identifier.url'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:description[@xml:lang='de-DE']">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.description.abstract'"/>
<xsl:with-param name="language" select="'de'"/>
<xsl:with-param name="value" select="replace(text(),'[‹›»«]','&quot;')"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:description[@xml:lang='en-US']">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.description.abstract'"/>
<xsl:with-param name="language" select="'en'"/>
<xsl:with-param name="value" select="replace(text(),'[‹›»«]','&quot;')"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:language">
<xsl:if test="position()=1">
<xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( text() )" />
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.language'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="$sanitizedLanguage"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="dc:identifier[matches(text(), '^10\..*')]">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.identifier.doi'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="concat('https://doi.org/', text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:identifier[matches(text(), '^urn.*')]">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.identifier.urn'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="dc:source">
<xsl:choose>
<xsl:when test="@xml:lang='de-DE'">
<xsl:variable name="pageInfo" select="tokenize( text(),'; ' )[last()]"/>
<xsl:variable name="volume" select="substring-before(substring-after(text(),'Bd. '),' ')"/>
<xsl:variable name="issue" select="tokenize(substring-after(text(),'Nr. '),' ')[1]"/>
<xsl:if test="string-length($pageInfo) &gt; 0">
<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:if test="string-length($volume) &gt; 0">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.volume'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="$volume"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="string-length($issue) &gt; 0">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.source.issue'"/>
<xsl:with-param name="language" select="''"/>
<xsl:with-param name="value" select="$issue"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="@xml:lang='en-US'">
<!-- hier kommt vielleicht gar nix hin. -->
</xsl:when>
<xsl:otherwise>
<!-- hier könnte man ncoh die ISSN auslesen, aber die ist eh immer gleich. -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--xsl:template match="dc:type[@xml:lang='en-US']">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.subject.other'"/>
<xsl:with-param name="language" select="'en'"/>
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:template-->
<xsl:template match="dc:title">
<xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( @xml:lang )" />
<xsl:variable name="sanitizedMainLanguage" select="zoai:sanitizeLanguage( /oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:language[1] )" />
<xsl:choose>
<xsl:when test="$sanitizedLanguage = $sanitizedMainLanguage">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.title'"/>
<xsl:with-param name="language" select="$sanitizedLanguage"/>
<xsl:with-param name="value" select="replace(text(),'[‹›»«]','&quot;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$sanitizedLanguage = 'uk' and $sanitizedMainLanguage = ''">
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.title'"/>
<xsl:with-param name="language" select="'uk'"/>
<xsl:with-param name="value" select="replace(text(),'[‹›»«]','&quot;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'dc.title.alternative'"/>
<xsl:with-param name="language" select="$sanitizedLanguage"/>
<xsl:with-param name="value" select="replace(text(),'[‹›»«]','&quot;')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</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' or $inputLanguage = 'DE' or $inputLanguage = 'de-DE' or $inputLanguage = 'deu'">
<xsl:value-of select="'de'" />
</xsl:when>
<xsl:when test="$inputLanguage = 'eng' or $inputLanguage = 'EN' or $inputLanguage = 'en-US' or $inputLanguage = 'en-GB'">
<xsl:value-of select="'en'" />
</xsl:when>
<xsl:when test="$inputLanguage = 'ukr' or $inputLanguage = 'uk-UA'">
<xsl:value-of select="'uk'" />
</xsl:when>
<xsl:when test="$inputLanguage = 'rus' or $inputLanguage = 'ru-RU'">
<xsl:value-of select="'ru'" />
</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