From e49585399a4b79b91264d46d9129e62cf3c4c975 Mon Sep 17 00:00:00 2001
From: Magnus Enger <magnus@enger.priv.no>
Date: Mon, 15 Apr 2013 21:56:53 +0200
Subject: [PATCH] Bug 10058 - Fix unapi for NORMARC

This patch uses a lot of MARC21 XSLT to transform NORMARC records
to desired formats. Since NORMARC is mostly a subset of MARC21, I
think this should give passable results. And better results than
no unapi-support at all for NORMARC!

To reproduce:
- Make sure you have marcflavour = NORMARC
- Visit /cgi-bin/koha/unapi in a browser
- Observe the empty <formats></formats> element

To test:
- Apply the patch
- Visit /cgi-bin/koha/unapi in a browser
- Observe the the list of formats in the <formats></formats> element
- Import the provided sample NORMARC record and make a note of its
  biblionumber
- View the record at /cgi-bin/koha/unapi?id=koha:biblionumber:x&format=y
  where x = the biblionumber of the sample record and y = one of the
  formats marcxml, marcxml-full, mods, mods-full, mods3, mods3-full,
  oai_dc, rdfdc, rss2, rss2-full and srw_dc
- Check that the transformed records make some kind of superficial
  sense

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
---
 opac/unapi |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/opac/unapi b/opac/unapi
index 0f97ece..6d8aec7 100755
--- a/opac/unapi
+++ b/opac/unapi
@@ -75,6 +75,19 @@ my $format_to_stylesheet_map = {
         'rss2-full'    => 'MARC21slim2RSS2.xsl',
         'srw_dc'       => 'MARC21slim2SRWDC.xsl',
     },
+    'NORMARC' => {
+        'marcxml'      => 'identity.xsl',
+        'marcxml-full' => 'identity.xsl',
+        'mods'         => 'MARC21slim2MODS.xsl',
+        'mods-full'    => 'MARC21slim2MODS.xsl',
+        'mods3'        => 'MARC21slim2MODS3-1.xsl',
+        'mods3-full'   => 'MARC21slim2MODS3-1.xsl',
+        'oai_dc'       => 'MARC21slim2OAIDC.xsl',
+        'rdfdc',       => 'MARC21slim2RDFDC.xsl',
+        'rss2'         => 'MARC21slim2RSS2.xsl',
+        'rss2-full'    => 'MARC21slim2RSS2.xsl',
+        'srw_dc'       => 'MARC21slim2SRWDC.xsl',
+    },
     'UNIMARC' => {
         'marcxml'      => 'identity.xsl',
         'marcxml-full' => 'identity.xsl',
-- 
1.7.10.4