Commit a4167e47 authored by Steinberg, Jan's avatar Steinberg, Jan

minnor ppn changes

parent 60a170de
......@@ -73,6 +73,49 @@ public class XsltMetadataTransformerTest {
assertEquals(18, transformedMetadata.size() );
}
@Test
public void testAnotherPicaxmlTransformation() throws IOException {
MetadataTransformer underTest = new XsltMetadataTransformer();
URL url = Resources.getResource("xslt/normalized-picaxml-to-metadataxml.xml");
String configuration= Resources.toString(url, Charsets.UTF_8);
LOG.info("configuration={}", configuration);
underTest.configure(configuration);
// from file DSA_2017_07_Teil-2-huebbegt.xlsx, "Traditionelle Boote in Deutschland. T. 1, Die Ruhrfähre von Oefte"
BundlesStreamSource source = new UnapiBundlesStreamSource("http://unapi.gbv.de", "picaxml", ImmutableList.of(), ImmutableList.of() );
Set<Metadatum> originalMetadata = source.getAllMetadata("gvk:ppn:729077314");
LOG.info("--------- BEGIN original metadata ------------");
originalMetadata.stream().map(Object::toString).forEach(LOG::info);
LOG.info("--------- END original metadata ------------");
Set<Metadatum> transformedMetadata = underTest.transformMetadata(originalMetadata);
LOG.info("--------- BEGIN transformed metadata ------------");
transformedMetadata.stream().map(Object::toString).forEach(LOG::info);
LOG.info("--------- END transformed metadata ------------");
assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.contributor.author", "Ancken, Rüdiger von") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.contributor.author", "Hanke, Fred") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.source.journal", "Deutsches Schiffahrtsarchiv") ) ) );
assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.language", "de") ) ) );
assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.title", "Traditionelle Boote in Deutschland , Teil 1: Die Ruhrfähre von Oefte") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.source.volume", "16") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.source.pageinfo", "211-228") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.rights.licence", "3") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.type.document", "32") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.type.stock", "article") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("ssoar.wgl.collection", "true") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("ssoar.contributor.institution", "DSM") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.date.issued", "1993") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.description.review", "3") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.description.pubstatus", "1") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.identifier.url", "http://nbn-resolving.de/urn:nbn:de:0168-ssoar-52582-3") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("internal.dda.reference", "http://unapi.gbv.de@@gvk:ppn:882380753") ) ) );
// assertTrue( transformedMetadata.stream().anyMatch( m -> m.equals( new SimpleMetadatum("dc.identifier.issn", "0343-3668") ) ) );
// assertEquals(18, transformedMetadata.size() );
}
@Test
public void testTransformationWithAdditionToTitle() throws IOException {
MetadataTransformer underTest = new XsltMetadataTransformer();
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pica="info:srw/schema/5/picaXML-v1.0"
exclude-result-prefixes="pica"
>
<xsl:output indent="yes" />
<xsl:strip-space elements="*"/>
<!-- <xsl:message terminate="no">here is the tree at the current node <xsl:copy-of select="."/> </xsl:message> -->
<!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
<!--
<xsl:for-each select="./*">
<xsl:message terminate="no">a child=<xsl:value-of select="name()"/></xsl:message>
</xsl:for-each>
-->
<xsl:template match="/">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="/record">
<publication>
<ssoar>
<wgl>
......@@ -27,11 +12,11 @@
</contributor>
</ssoar>
<dc>
<!--source>
<source>
<journal>
Deutsches Schiffahrtsarchiv
</journal>
</source-->
</source>
<language>de</language>
<rights>
<licence>3</licence>
......@@ -47,103 +32,77 @@
<identifier>
<issn>0343-3668</issn>
</identifier>
<xsl:for-each select="record/datafield">
<xsl:if test="./tag = '31A'">
<source>
<volume>
<xsl:value-of select="./subfield/content"/>
</volume>
</source>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="pica:record" />
</dc>
<xsl:variable name="preferredMainTitle" select="datafield[tag='039I']/subfield[code='t']/content" />
<xsl:variable name="mainTitle">
<xsl:choose>
<xsl:when test="$preferredMainTitle != ''">
<xsl:value-of select="$preferredMainTitle" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="datafield[tag='021A']/subfield[code='a']/content" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="datafield[tag='021A']">
<dc>
<title>
<xsl:value-of select="$mainTitle"/><xsl:if test="subfield[code='d']">: <xsl:value-of select="subfield[code='d']/content"/></xsl:if>
</title>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='031A']">
<dc>
<source>
<volume>
<xsl:value-of select="subfield[code='d']/content"/>
</volume>
<pageinfo>
<xsl:value-of select="subfield[code='h']/content"/>
</pageinfo>
</source>
<date>
<issued>
<xsl:value-of select="subfield[code='j']/content"/>
</issued>
</date>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='028A']">
<dc>
<contributor>
<author>
<xsl:value-of select="subfield[code='a']/content"/>, <xsl:value-of select="subfield[code='d']/content"/>
<xsl:if test="subfield[code='d']/content"><xsl:text> </xsl:text><xsl:value-of select="subfield[code='c']/content"/></xsl:if>
</author>
</contributor>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='028C']">
<dc>
<contributor>
<author>
<xsl:value-of select="subfield[code='a']/content"/>, <xsl:value-of select="subfield[code='d']/content"/>
</author>
</contributor>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='009P']">
<dc>
<identifier>
<url>
<xsl:value-of select="subfield[code='a']/content"/>
</url>
</identifier>
</dc>
</xsl:for-each>
</publication>
</xsl:template>
<xsl:template match="pica:record">
<!--xsl:apply-templates select="pica:datafield[@tag='021A']"/-->
<xsl:apply-templates select="pica:datafield[@tag='031A']"/>
<xsl:apply-templates select="pica:datafield[@tag='028A']"/>
<xsl:apply-templates select="pica:datafield[@tag='027D']"/>
<xsl:apply-templates select="pica:datafield[@tag='028C']"/>
<xsl:apply-templates select="pica:datafield[@tag='009P']"/>
</xsl:template>
<!--xsl:template match="pica:datafield[@tag='021A']">
<dc>
<title>
</title>
</dc>
</xsl:template-->
<xsl:template match="pica:datafield[@tag='031A']">
<source>
<xsl:if test="pica:subfield[@code='d']/text()">
<volume>
<xsl:value-of select="pica:subfield[@code='d']/text()"/>
</volume>
</xsl:if>
<xsl:if test="pica:subfield[@code='h']/text()">
<pageinfo>
<xsl:value-of select="pica:subfield[@code='h']/text()"/>
</pageinfo>
</xsl:if>
</source>
<xsl:if test="pica:subfield[@code='j']/text()">
<date>
<issued>
<xsl:value-of select="pica:subfield[@code='j']/text()"/>
</issued>
</date>
</xsl:if>
<xsl:choose>
<xsl:when test="string-length(/pica:record/pica:datafield[@tag='039I']/pica:subfield[@code='t']/text()) > 0">
<title>
<xsl:value-of select="/pica:record/pica:datafield[@tag='039I']/pica:subfield[@code='t']/text()"/>
</title>
</xsl:when>
<xsl:otherwise>
<title>
<xsl:value-of select="/pica:record/pica:datafield[@tag='021A']/pica:subfield[@code='a']/text()"/>
<xsl:if test="/pica:record/pica:datafield[@tag='021A']/pica:subfield[@code='d']">
<xsl:text>: </xsl:text>
<xsl:value-of select="/pica:record/pica:datafield[@tag='021A']/pica:subfield[@code='d']/text()"/>
</xsl:if>
</title>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="pica:datafield[@tag='028A']">
<contributor>
<author>
<xsl:value-of select="pica:subfield[@code='a'][1]/text()"/>, <xsl:value-of select="pica:subfield[@code='d'][1]/text()"/>
</author>
</contributor>
</xsl:template>
<xsl:template match="pica:datafield[@tag='027D']">
<source>
<journal>
<xsl:value-of select="pica:subfield[@code='a']/text()"/>
</journal>
</source>
</xsl:template>
<xsl:template match="pica:datafield[@tag='028C']">
<contributor>
<author>
<xsl:value-of select="pica:subfield[@code='a'][1]/text()"/>, <xsl:value-of select="pica:subfield[@code='d'][1]/text()"/>
</author>
</contributor>
</xsl:template>
<xsl:template match="pica:datafield[@tag='009P']">
<identifier>
<url>
<xsl:value-of select="pica:subfield[@code='a']/text()"/>
</url>
</identifier>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="/record">
<publication>
<ssoar>
<wgl>
<collection>true</collection>
</wgl>
<contributor>
<institution>DSM</institution>
</contributor>
</ssoar>
<dc>
<source>
<journal>
Deutsches Schiffahrtsarchiv
</journal>
</source>
<language>de</language>
<rights>
<licence>3</licence>
</rights>
<type>
<document>32</document>
<stock>article</stock>
</type>
<description>
<review>3</review>
<pubstatus>1</pubstatus>
</description>
<identifier>
<issn>0343-3668</issn>
</identifier>
</dc>
<xsl:for-each select="datafield[tag='021A']">
<dc>
<title>
<xsl:choose>
<xsl:when test="../datafield[tag='039I']/subfield[code='t']/content">
<xsl:value-of select="../datafield[tag='039I']/subfield[code='t']/content"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="subfield[code='a']/content" />
</xsl:otherwise>
</xsl:choose>
<xsl:if test="subfield[code='d']"><xsl:text>: </xsl:text><xsl:value-of select="subfield[code='d']/content"/></xsl:if>
</title>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='031A']">
<dc>
<source>
<volume>
<xsl:value-of select="subfield[code='d']/content"/>
</volume>
<pageinfo>
<xsl:value-of select="subfield[code='h']/content"/>
</pageinfo>
</source>
<date>
<issued>
<xsl:value-of select="subfield[code='j']/content"/>
</issued>
</date>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='028A']">
<dc>
<contributor>
<author>
<xsl:value-of select="subfield[code='a']/content"/>, <xsl:value-of select="subfield[code='d']/content"/>
</author>
</contributor>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='028C']">
<dc>
<contributor>
<author>
<xsl:value-of select="subfield[code='a']/content"/>, <xsl:value-of select="subfield[code='d']/content"/>
</author>
</contributor>
</dc>
</xsl:for-each>
<xsl:for-each select="datafield[tag='009P']">
<dc>
<identifier>
<url>
<xsl:value-of select="subfield[code='a']/content"/>
</url>
</identifier>
</dc>
</xsl:for-each>
</publication>
</xsl:template>
</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