diff --git a/public/instance/proxy/opac-de-23/index.php b/public/instance/proxy/opac-de-23/index.php index 7258161a2aaa0dc3102c66e5d5561919c72c10a9..55c4b34fd3107e390d992d1a99bcb08566e78557 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 0000000000000000000000000000000000000000..048686eefbcacb8d43a99fe6884f42c86336159c --- /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>