[open-ils-commits] r10244 - in branches/rel_1_2/Open-ILS: examples src/perlmods/OpenILS/Application/Search

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Aug 4 02:36:26 EDT 2008


Author: miker
Date: 2008-08-04 02:36:18 -0400 (Mon, 04 Aug 2008)
New Revision: 10244

Modified:
   branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
   branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
Log:
add support for xml-based z servers (such as xml-backed zebra without yaz-proxy)

Modified: branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
===================================================================
--- branches/rel_1_2/Open-ILS/examples/opensrf.xml.example	2008-08-04 01:25:53 UTC (rev 10243)
+++ branches/rel_1_2/Open-ILS/examples/opensrf.xml.example	2008-08-04 06:36:18 UTC (rev 10244)
@@ -93,8 +93,14 @@
                     <host>z3950.loc.gov</host>
                     <port>7090</port>
                     <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>

Modified: branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
===================================================================
--- branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm	2008-08-04 01:25:53 UTC (rev 10243)
+++ branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm	2008-08-04 06:36:18 UTC (rev 10244)
@@ -159,6 +159,8 @@
 	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');
@@ -168,7 +170,7 @@
 		databaseName				=> $db, 
 		user							=> $username,
 		password						=> $password,
-		preferredRecordSyntax	=> $output, 
+		preferredRecordSyntax	=> $tformat, 
 	);
 
 	if( ! $connection ) {
@@ -212,6 +214,7 @@
 	my $offset	= shift;
     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'");
@@ -239,7 +242,15 @@
 		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 );
@@ -287,9 +298,11 @@
  		next unless ( exists $services{$service}->{attrs}->{$_} );
         $str .= '@attr 1=' . $services{$service}->{attrs}->{$_}->{code} . # add the use attribute
 			' @attr 4=' . $services{$service}->{attrs}->{$_}->{format}; # add the structure attribute
+
 		if (exists $services{$service}->{attrs}->{$_}->{truncation}){
 			$str .= ' @attr 5=' . $services{$service}->{attrs}->{$_}->{truncation};
 		}
+
 		$str .= " \"" . $$hash{$_} . "\" "; # add the search term
 	}
 	return $str;



More information about the open-ils-commits mailing list