[Koha-patches] [PATCH] Bug #3087 - Improve z39.50 server Unimarc support

Frédéric Demians f.demians at tamil.fr
Fri Apr 3 14:45:33 CEST 2009


With this patch, it's possible to configure Zebra server in order
to return biblio records with a consistent Unimarc 'format'.

Some improvements are still required:

  * Koha installation program need to be modified to pick up
    koha-conf-unimarc.xml in place of koha-conf.xml.
  * XSL file could be added to transform MARCXML Unimarc
    into OAI, MODS. But this is another story...
---
 C4/Search.pm                                     |    3 +
 etc/koha-conf-unimarc.xml                        |  194 ++++++++++++++++++++++
 etc/zebradb/etc/unimarc.mar                      |    3 +
 etc/zebradb/marc_defs/unimarc/biblios/record.abs |    4 +-
 4 files changed, 202 insertions(+), 2 deletions(-)
 create mode 100644 etc/koha-conf-unimarc.xml
 create mode 100644 etc/zebradb/etc/unimarc.mar

diff --git a/C4/Search.pm b/C4/Search.pm
index 10f8219..0323a1b 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -342,6 +342,9 @@ sub getRecords {
 # perform the search, create the results objects
 # if this is a local search, use the $koha-query, if it's a federated one, use the federated-query
         my $query_to_use = ($servers[$i] =~ /biblioserver/) ? $koha_query : $simple_query;
+        if ( $servers[$i] =~ /biblioserver/ && C4::Context->preference("marcflavour") eq "UNIMARC" ) {
+            $zconns[$i]->option( preferredRecordSyntax => "unimarc" );
+        }
 
         #$query_to_use = $simple_query if $scan;
         warn $simple_query if ( $scan and $DEBUG );
diff --git a/etc/koha-conf-unimarc.xml b/etc/koha-conf-unimarc.xml
new file mode 100644
index 0000000..4547c1c
--- /dev/null
+++ b/etc/koha-conf-unimarc.xml
@@ -0,0 +1,194 @@
+
+<yazgfs>
+<!-- [scheme:]host[:port][/databaseName] -->
+<!-- scheme: tcp, ssl, unix, http, sru -->
+<!-- can run all servers on tcp, but the unix socket is faster -->
+
+<listen id="biblioserver" >unix:__ZEBRA_RUN_DIR__/bibliosocket</listen>
+<listen id="authorityserver" >unix:__ZEBRA_RUN_DIR__/authoritysocket</listen>
+<!-- public server runs on tcp -->
+<!-- <listen id="publicserver" >tcp:@:9999</listen> -->
+
+<!-- Settings for special biblio server instance for PazPar2.
+     Because PazPar2 only connects to a Z39.50 server using TCP/IP,
+     it cannot use the Unix-domain socket that biblioserver uses.
+     Therefore, a custom server is defined. -->
+__PAZPAR2_TOGGLE_XML_PRE__
+<listen id="mergeserver">tcp:@:__MERGE_SERVER_PORT__</listen>
+<server id="mergeserver"  listenref="mergeserver"> 
+    <directory>__ZEBRA_DATA_DIR__/biblios</directory>
+    <config>__ZEBRA_CONF_DIR__/zebra-biblios.cfg</config>
+    <cql2rpn>__ZEBRA_CONF_DIR__/pqf.properties</cql2rpn>
+</server>
+__PAZPAR2_TOGGLE_XML_POST__
+
+<!-- BIBLIOGRAPHIC RECORDS -->
+<server id="biblioserver"  listenref="biblioserver"> 
+    <directory>__ZEBRA_DATA_DIR__/biblios</directory>
+    <config>__ZEBRA_CONF_DIR__/zebra-biblios.cfg</config>
+    <cql2rpn>__ZEBRA_CONF_DIR__/pqf.properties</cql2rpn>
+     <!-- <docpath>xsl</docpath> -->
+     <!-- <stylesheet>xsl/default.xsl</stylesheet> -->
+     <!-- <maximumrecordsize>2000000</maximumrecordsize> -->
+     <retrievalinfo>
+       <retrieval syntax="unimarc" name="F"/>
+       <retrieval syntax="unimarc" name="B"/>
+       <retrieval syntax="xml" name="F"/>
+       <retrieval syntax="xml" name="B"/>
+       <retrieval syntax="xml" name="marcxml"
+                  identifier="info:srw/schema/1/marcxml-v1.1">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="dc">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2DC.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="mods">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2MODS.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="rdfdc">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2RDFDC.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="rss2">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2RSS2.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="utils">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slimUtils.xsl"/>
+         </backend>
+       </retrieval>
+     </retrievalinfo>
+    <xi:include href="__KOHA_CONF_DIR__/zebradb/explain-biblios.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude">
+      <xi:fallback>
+      <explain xmlns="http://explain.z3950.org/dtd/2.0/">
+          <serverInfo>
+            <host>__ZEBRA_SRU_HOST__</host>
+            <port>__ZEBRA_SRU_BIBLIOS_PORT__</port>
+            <database>biblios</database>
+          </serverInfo>
+        </explain>
+      </xi:fallback>
+    </xi:include>
+</server>
+<serverinfo id="biblioserver">
+        <ccl2rpn>__ZEBRA_CONF_DIR__/ccl.properties</ccl2rpn>
+        <user>__ZEBRA_USER__</user>    
+        <password>__ZEBRA_PASS__</password>
+</serverinfo>
+
+<!-- AUTHORITY RECORDS -->
+<server id="authorityserver"  listenref="authorityserver" >
+    <directory>__ZEBRA_DATA_DIR__/authorities</directory>
+    <config>__ZEBRA_CONF_DIR__/__ZEBRA_AUTH_CFG__</config>
+    <cql2rpn>__ZEBRA_CONF_DIR__/pqf.properties</cql2rpn>
+     <!-- <docpath>xsl</docpath> -->
+     <!-- <stylesheet>xsl/default.xsl</stylesheet> -->
+     <!-- <maximumrecordsize>2000000</maximumrecordsize> -->
+    <xi:include href="__KOHA_CONF_DIR__/zebradb/__AUTH_RETRIEVAL_CFG__"
+                xmlns:xi="http://www.w3.org/2001/XInclude">
+      <xi:fallback>
+     <retrievalinfo>
+       <retrieval syntax="unimarc" name="F"/>
+       <retrieval syntax="unimarc" name="B"/>
+       <retrieval syntax="xml" name="marcxml"
+                  identifier="info:srw/schema/1/marcxml-v1.1">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="dc">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2DC.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="mods">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2MODS.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="rdfdc">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slim2RDFDC.xsl"/>
+         </backend>
+       </retrieval>
+       <retrieval syntax="xml" name="utils">
+         <backend syntax="unimarc" name="F">
+           <marc inputformat="marc" outputformat="marcxml"
+                 inputcharset="utf-8"/>
+           <xslt stylesheet="__INTRANET_TMPL_DIR__/prog/en/xslt/MARC21slimUtils.xsl"/>
+         </backend>
+       </retrieval>
+     </retrievalinfo>
+      </xi:fallback>
+    </xi:include>
+    <xi:include href="__KOHA_CONF_DIR__/zebradb/explain-authorities.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude">
+      <xi:fallback>
+      <explain xmlns="http://explain.z3950.org/dtd/2.0/">
+          <serverInfo>
+            <host>__ZEBRA_SRU_HOST__</host>
+            <port>__ZEBRA_SRU_AUTHORITIES_PORT__</port>
+            <database>authorities</database>
+          </serverInfo>
+        </explain>
+      </xi:fallback>
+    </xi:include>
+</server>
+<serverinfo id="authorityserver">
+    <ccl2rpn>__ZEBRA_CONF_DIR__/ccl.properties</ccl2rpn>
+    <user>__ZEBRA_USER__</user>
+    <password>__ZEBRA_PASS__</password>
+</serverinfo>
+
+<!-- ADDITIONAL KOHA CONFIGURATION DIRECTIVE -->
+<!-- db_scheme should follow the DBD driver name --> 
+<!-- port info: mysql:3306 Pg:5432 (5433 on Debian) -->
+<config>
+ <db_scheme>__DB_TYPE__</db_scheme>
+ <database>__DB_NAME__</database>
+ <hostname>__DB_HOST__</hostname>
+ <port>__DB_PORT__</port>
+ <user>__DB_USER__</user>
+ <pass>__DB_PASS__</pass>
+ <biblioserver>biblios</biblioserver>
+ <biblioservershadow>1</biblioservershadow>
+ <authorityserver>authorities</authorityserver>
+ <authorityservershadow>1</authorityservershadow>
+ <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
+ <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
+ <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>
+ <intrahtdocs>__INTRANET_TMPL_DIR__</intrahtdocs>
+ <includes>__INTRANET_TMPL_DIR__/prog/en/includes/</includes>
+ <logdir>__LOG_DIR__</logdir>
+ <pazpar2url>http://__PAZPAR2_HOST__:__PAZPAR2_PORT__/search.pz2</pazpar2url>
+ <install_log>__MISC_DIR__/koha-install-log</install_log>
+</config>
+</yazgfs>
diff --git a/etc/zebradb/etc/unimarc.mar b/etc/zebradb/etc/unimarc.mar
new file mode 100644
index 0000000..591e9d9
--- /dev/null
+++ b/etc/zebradb/etc/unimarc.mar
@@ -0,0 +1,3 @@
+# $Id: usmarc.mar,v 1.1 2002/10/22 12:51:09 adam Exp $
+name unimarc
+reference Unimarc
diff --git a/etc/zebradb/marc_defs/unimarc/biblios/record.abs b/etc/zebradb/marc_defs/unimarc/biblios/record.abs
index 7c502af..0801c23 100644
--- a/etc/zebradb/marc_defs/unimarc/biblios/record.abs
+++ b/etc/zebradb/marc_defs/unimarc/biblios/record.abs
@@ -10,13 +10,13 @@
 # internal structure.
 
 encoding utf-8
-name marc21
+name unimarc
 attset bib1.att
 attset gils.att
 esetname F @
 esetname B @
 
-marc usmarc.mar
+marc unimarc.mar
 systag sysno rank
 xpath disable
 
-- 
1.5.6.5




More information about the Koha-patches mailing list