Skip to content
Snippets Groups Projects
Commit 472de766 authored by David Maus's avatar David Maus
Browse files

RDF/XML für OPAC Titeldaten

parent 3694252d
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ use HAB\Pica\Writer\PicaXmlWriter;
define('PSI_TEMPLATE', 'http://opac.lbs-braunschweig.gbv.de/DB=2/PLAIN=Y/CHARSET=UTF8/PLAINTTLCHARSET=UTF8/PPN?PPN=%s');
define('PICA_TEMPLATE', 'http://uri.hab.de/instance/proxy/opac-de-23/%s.xml');
define('MODS_TEMPLATE', 'http://uri.hab.de/instance/proxy/opac-de-23/%s.mods');
define('RDF_TEMPLATE', 'http://uri.hab.de/instance/proxy/opac-de-23/%s.rdf');
function terminate (Request $request, Response $response) {
......@@ -25,6 +26,7 @@ function terminate (Request $request, Response $response) {
function load ($ident) {
$content = @file_get_contents(sprintf(PSI_TEMPLATE, $ident));
if ($content) {
$content = normalizer_normalize($content);
$reader = new PicaNormReader();
$reader->open($content);
return $reader->read();
......@@ -103,6 +105,14 @@ switch ($format) {
$response = new Response($content, 200, array('Content-Type' => 'application/rdf+xml'));
break;
}
} else {
$templateUri = __DIR__ . '/../../../../src/xslt/mods2rdf.xsl';
$sourceUri = sprintf(MODS_TEMPLATE, $ident);
$content = transform($sourceUri, $templateUri);
if ($content) {
$response = new Response($content, 200, array('Content-Type' => 'application/rdf+xml'));
break;
}
}
$response = new Response('<h1>406 Not Acceptable</h1>', 406, array('Content-Type' => 'text/html'));
break;
......
<xsl:transform version="1.0"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:marcrel="http://id.loc.gov/vocabulary/relators/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdau="http://rdaregistry.info/Elements/u/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="proxyBaseUrl">http://uri.hab.de/instance/proxy/opac-de-23/</xsl:variable>
<xsl:template match="mods:mods">
<rdf:RDF>
<dct:BibliographicResource rdf:about="{$proxyBaseUrl}{mods:recordInfo/mods:recordIdentifier}">
<skos:prefLabel>
<!-- Verfasser -->
<xsl:if test="mods:name[mods:role/mods:roleTerm = 'aut'][mods:namePart[@type = 'family' or @type = 'given']]">
<xsl:for-each select="mods:name[mods:role/mods:roleTerm = 'aut'][mods:namePart[@type = 'family' or @type = 'given']]">
<xsl:if test="position() > 1">
<xsl:text>; </xsl:text>
</xsl:if>
<xsl:if test="mods:namePart[@type = 'family'] and mods:namePart[@type = 'given']">
<xsl:value-of select="mods:namePart[@type = 'family']"/>
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="mods:namePart[@type = 'given']"/>
</xsl:for-each>
<xsl:text>: </xsl:text>
</xsl:if>
<!-- Titel -->
<xsl:value-of select="mods:titleInfo[not(preceding-sibling::mods:titleInfo)]/mods:title"/>
<xsl:text>. - </xsl:text>
<!-- Ort und Verlage -->
<xsl:for-each select="mods:originInfo[mods:dateIssued]/mods:place">
<xsl:if test="position() > 1">
<xsl:text>; </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:if test="mods:originInfo[mods:dateIssued]/mods:place and mods:originInfo[mods:dateIssued]/mods:publisher">
<xsl:text> : </xsl:text>
</xsl:if>
<xsl:for-each select="mods:originInfo[mods:dateIssued]/mods:publisher">
<xsl:if test="position() > 1">
<xsl:text>; </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
<!-- Datum -->
<xsl:if test="mods:originInfo[mods:dateIssued]/mods:place or mods:originInfo[mods:dateIssued]/mods:publisher">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="mods:originInfo/mods:dateIssued"/>
<!-- Signatur -->
<xsl:if test="mods:location/mods:shelfLocator">
<xsl:text>. - HAB Wolfenbüttel </xsl:text>
<xsl:value-of select="mods:location/mods:shelfLocator[1]"/>
</xsl:if>
</skos:prefLabel>
<xsl:apply-templates/>
</dct:BibliographicResource>
</rdf:RDF>
</xsl:template>
<xsl:template match="mods:mods/mods:titleInfo[not(preceding-sibling::mods:titleInfo)]">
<dct:title>
<xsl:value-of select="normalize-space(concat(mods:nonSort, ' ', mods:title))"/>
<xsl:if test="mods:subTitle">
<xsl:value-of select="concat(' : ', mods:subTitle)"/>
</xsl:if>
</dct:title>
</xsl:template>
<xsl:template match="mods:language/mods:languageTerm[@type = 'code'][@authority = 'iso639-2b']">
<dct:language>
<skos:Concept>
<owl:sameAs rdf:resource="http://id.loc.gov/vocabulary/iso639-2/{.}"/>
<skos:prefLabel><xsl:value-of select="."/></skos:prefLabel>
</skos:Concept>
</dct:language>
</xsl:template>
<xsl:template match="mods:subject[@authority = 'gnd']/mods:topic">
<dct:subject>
<skos:Concept>
<xsl:choose>
<xsl:when test="starts-with(@valueURI, 'http://uri.hab.de')">
<xsl:attribute name="rdf:about"><xsl:value-of select="@valueURI"/></xsl:attribute>
</xsl:when>
<xsl:when test="@valueURI">
<owl:sameAs rdf:resource="{@valueURI}"/>
</xsl:when>
</xsl:choose>
<skos:prefLabel><xsl:value-of select="."/></skos:prefLabel>
</skos:Concept>
</dct:subject>
</xsl:template>
<xsl:template match="mods:classification">
<dct:subject>
<skos:Concept>
<xsl:choose>
<xsl:when test="starts-with(@valueURI, 'http://uri.hab.de')">
<xsl:attribute name="rdf:about"><xsl:value-of select="@valueURI"/></xsl:attribute>
</xsl:when>
<xsl:when test="@valueURI">
<owl:sameAs rdf:resource="{@valueURI}"/>
</xsl:when>
</xsl:choose>
<skos:prefLabel><xsl:value-of select="."/></skos:prefLabel>
</skos:Concept>
</dct:subject>
</xsl:template>
<xsl:template match="mods:originInfo[mods:dateIssued]">
<dct:issued><xsl:value-of select="mods:dateIssued"/></dct:issued>
<xsl:if test="mods:place/mods:placeTerm[@type = 'text']">
<rdau:P60163><xsl:value-of select="mods:place/mods:placeTerm[@type = 'text']"/></rdau:P60163>
</xsl:if>
<xsl:if test="mods:publisher">
<rdau:P60547><xsl:value-of select="mods:publisher"/></rdau:P60547>
</xsl:if>
</xsl:template>
<xsl:template match="mods:name[@type = 'personal'][mods:role/mods:roleTerm[@authority = 'marcrelator' and @type = 'code']]">
<xsl:element name="marcrel:{mods:role/mods:roleTerm[@authority = 'marcrelator' and @type = 'code']}">
<dct:Agent>
<xsl:if test="@valueURI">
<owl:sameAs rdf:resource="{@valueURI}"/>
</xsl:if>
<skos:prefLabel><xsl:value-of select="mods:displayForm"/></skos:prefLabel>
</dct:Agent>
</xsl:element>
</xsl:template>
<xsl:template match="text()"/>
</xsl:transform>
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