add support for xml-based z servers (such as xml-backed zebra without yaz-proxy)
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Aug 2008 06:55:57 +0000 (06:55 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Aug 2008 06:55:57 +0000 (06:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10245 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/opensrf.xml.example
Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm

index 94eb200..6bd3e02 100644 (file)
@@ -98,6 +98,11 @@ vim:et:ts=4:sw=4:
                     <db>Voyager</db>
                     <!-- fetch the full record with no holdings. FI is the default -->
                     <record_format>FI</record_format> 
+
+                    <!-- Record transmission format from the server.  Supported -->
+                    <!-- formats include usemarc and xml (for marcxml).         -->
+                    <transmission_format>usmarc</transmission_format> 
+
                     <attrs>
                         <tcn><code>12</code><format>1</format></tcn>
                         <isbn><code>7</code><format>6</format></isbn>
index ff661fd..8d92005 100755 (executable)
@@ -200,6 +200,8 @@ sub do_search {
        my $username = $$args{username} || "";
        my $password = $$args{password} || "";
 
+    my $tformat = $services{$service}->{transmission_format} || $output;
+
        my $editor = new_editor(authtoken => $auth);
        return $editor->event unless $editor->checkauth;
        return $editor->event unless $editor->allowed('REMOTE_Z3950_QUERY');
@@ -210,7 +212,7 @@ sub do_search {
                user                                                    => $username,
                password                                                => $password,
                async                                                   => $async,
-               preferredRecordSyntax   => $output, 
+               preferredRecordSyntax   => $tformat, 
        );
 
        if( ! $connection ) {
@@ -256,6 +258,7 @@ sub process_results {
        my $offset      = shift || 0;
     my $service = shift;
 
+    my $tformat = $services{$service}->{transmission_format} || $output;
     my $rformat = $services{$service}->{record_format} || 'FI';
        $results->option(elementSetName => $rformat);
     $logger->info("z3950: using record format '$rformat'");
@@ -283,7 +286,15 @@ sub process_results {
                try {
 
                        my $rec = $results->record($_);
-                       $marc           = MARC::Record->new_from_usmarc($rec->raw());
+
+            if ($tformat eq 'usmarc') {
+                       $marc           = MARC::Record->new_from_usmarc($rec->raw());
+            } else if ($tformat eq 'xml') {
+                       $marc           = MARC::Record->new_from_xml($rec->raw());
+            } else {
+                die "Unsupported record transmission format $tformat"
+            }
+
                        $marcs  = entityize($marc->as_xml_record);
                        my $doc = XML::LibXML->new->parse_string($marcs);
                        $marcxml = entityize( $doc->documentElement->toString );