From c223cb8701ca2381d7f4d2bfcadcfb2c4d3ab234 Mon Sep 17 00:00:00 2001 From: David Maus <maus@hab.de> Date: Wed, 18 Apr 2018 16:26:32 +0200 Subject: [PATCH] =?UTF-8?q?MODS=20f=C3=BCr=20OPAC=20Titeldaten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/instance/proxy/opac-de-23/index.php | 20 +++++++++- src/xslt/{pica2skos.xsl => pica/auth.xsl} | 0 src/xslt/pica/mods.xsl | 45 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) rename src/xslt/{pica2skos.xsl => pica/auth.xsl} (100%) create mode 100644 src/xslt/pica/mods.xsl diff --git a/public/instance/proxy/opac-de-23/index.php b/public/instance/proxy/opac-de-23/index.php index 7258161a2..55c4b34fd 100644 --- a/public/instance/proxy/opac-de-23/index.php +++ b/public/instance/proxy/opac-de-23/index.php @@ -67,18 +67,34 @@ switch ($format) { $content = $writer->write($record); $response = new Response($content, 200, array('Content-Type' => 'application/xml')); break; + case 'mods': + $type = (string)$record->getFirstMatchingField('002@/00')->getNthSubfield(0, '0'); + if ($type[0] === 'T') { + $response = new Response('<h1>406 Not Acceptable</h1>', 406, array('Content-Type' => 'text/html')); + } else { + $templateUri = __DIR__ . '/../../../../src/xslt/pica/mods.xsl'; + $sourceUri = sprintf(PICA_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; case 'rdf': $type = (string)$record->getFirstMatchingField('002@/00')->getNthSubfield(0, '0'); if ($type[0] === 'T') { + $templateUri = __DIR__ . '/../../../../src/xslt/pica/auth.xsl'; $sourceUri = sprintf(PICA_TEMPLATE, $ident); - $templateUri = __DIR__ . '/../../../../src/xslt/pica2skos.xsl'; $content = transform($sourceUri, $templateUri); if ($content) { $response = new Response($content, 200, array('Content-Type' => 'application/rdf+xml')); break; } } - // Fall through + $response = new Response('<h1>406 Not Acceptable</h1>', 406, array('Content-Type' => 'text/html')); + break; default: $response = new Response('<h1>406 Not Acceptable</h1>', 406, array('Content-Type' => 'text/html')); } diff --git a/src/xslt/pica2skos.xsl b/src/xslt/pica/auth.xsl similarity index 100% rename from src/xslt/pica2skos.xsl rename to src/xslt/pica/auth.xsl diff --git a/src/xslt/pica/mods.xsl b/src/xslt/pica/mods.xsl new file mode 100644 index 000000000..048686eef --- /dev/null +++ b/src/xslt/pica/mods.xsl @@ -0,0 +1,45 @@ +<xsl:transform version="1.0" + xmlns:mods="http://www.loc.gov/mods/v3" + xmlns:pica="info:srw/schema/5/picaXML-v1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:template match="pica:record"> + <xsl:variable name="recordType" select="substring(pica:datafield[@tag = '002@']/pica:subfield[@code = '0'], 2, 1)"/> + + <mods:mods> + <xsl:choose> + <xsl:when test="pica:datafield[@tag = '021A']"> + <xsl:call-template name="mods:titleInfo"> + <xsl:with-param name="titleField" select="pica:datafield[@tag = '021A']"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> + </mods:mods> + </xsl:template> + + <xsl:template name="mods:titleInfo"> + <xsl:param name="titleField"/> + + <mods:titleInfo> + <xsl:choose> + <xsl:when test="contains($titleField/pica:subfield[@code = 'a'], '@')"> + <xsl:if test="substring-before($titleField/pica:subfield[@code = 'a'], '@')"> + <mods:nonSort> + <xsl:value-of select="substring-before($titleField/pica:subfield[@code = 'a'], '@')"/> + </mods:nonSort> + <mods:title> + <xsl:value-of select="substring-after($titleField/pica:subfield[@code = 'a'], '@')"/> + </mods:title> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <mods:title> + <xsl:value-of select="$titleField/pica:subfield[@code = 'a']"/> + </mods:title> + </xsl:otherwise> + </xsl:choose> + </mods:titleInfo> + + </xsl:template> + +</xsl:transform> -- GitLab