Thanks, Ben.  

I thought it might eventually come down to this.

I've been using Yaz and the ZOOM API for other applications --
specifically with VBZoom, the Visual Basic cousin to Net::Z3950.  I
agree, it is much nicer.

The module I'm working on is an extension of a commercial product, so
I'm going to have to lobby the vendor to switch from Zeta to Net:Z3950,
which I think they may be inclined to do anyway.  It just pushes my
development timeline back.

Thanks again.  Hopefully, I'll be putting your code to work soon!

--Dave

============================
David Walker
Web Developer
Library
California State University, San Marcos
ph: (760) 750-4379
============================

-----Original Message-----
From: Ben Soares [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 28, 2004 3:52 AM
To: [EMAIL PROTECTED]
Cc: David Walker
Subject: Re: Zeta Perl Opac Format

Hi David,

I did use Zeta perl some time ago, but when it stopped being supported
switched over to using Net::Z3950 -- it has a much cleaner
object-oriented API and is under active development.  The following
script will do what you want using the latest CPAN release of Net::Z3950
(note to install Net::Z3950 you need a recent version of yaz installed
<http://www.indexdata.com/yaz/>.


#!/home/cpan/bin/perl

use strict;
use Net::Z3950;

my $issn = "0098-7484";
my $query = '@attrset bib1 @attr 1=8 '.$issn;

my $target = "pac.csusm.edu";
my $port = 210;
my $database = "Innopac";
my $format = "b";
my $syntax = Net::Z3950::RecordSyntax::OPAC;

my $zc =
Net::Z3950::Connection->new($target,$port,databaseName=>$database)
or die("Could not connect to $target:$port"); my $rs =
$zc->search(-prefix => $query) or die("Could not retrieve resultset");
$rs->option(preferredRecordSyntax => $syntax);
$rs->option(elementSetName => $format); if ($rs->size() == 0) {
  warn("no results\n");
  exit 0;
}
for (my $n = 1; $n <= $rs->size(); $n++) {
  my $rec = $rs->record($n);
  print "$n\n";
  print $rec->render();
}


Hope this might be of some use to you (if you get Net::Z3950 installed),

Ben


On Mon, 26 April, 2004 17:36, David Walker wrote:
> Hi All,
>
> I'm developing a script for an application that uses Zeta Perl for 
> Z39.50 connections.  I'm hoping those of you familiar with Zeta Perl 
> can help me with this.
>
> When I specify the record syntax as MARC or SUTRS everything works
fine.
> But when I specify the record syntax as "OPAC," using the OID 
> 1.2.840.10003.5.102, I get nothing.  Actually, I get a result set from

> the Z39.50 target, but when I try to print the results, nothing is 
> outputted to the screen.
>
> I know the target is capable of returning records in OPAC format -- 
> which I take is some type of MARC XML? -- since I can successfully 
> query and display the results using other Z39.50 applications.
>
> I have a feeling the problem lies more with my limited knowledge of 
> Perl rather than something specific with the Zeta module.
>
> Here's my code:
>
> ================
>
> use Zeta;
>
> &lookup;
>
> sub lookup {
>
>       my $issn = "0098-7484";
>
>       my $target = "pac.csusm.edu";
>       my $port = 210;
>       my $database = "Innopac";
>
>       my $resultset = "zeta";
>       my $query = "1=8 " . $issn;
>       my $attrid = "BIB1";
>       my $start = 1;
>       my $format = "b";
>       my $howmany = 1;
>       my $syntax = "1.2.840.10003.5.102"; #OPAC
>
>       my @holdings = ();
>
>       #establish a connection with a Z39.50 Target over TCP/IP
>       $zc = Zeta::Connection::New ($target, $port);
>
>       if (! $zc) {
>               $strError ="couldn't connect to target\n";
>       } else {
>
>               # initialize the association
>               ($status, $reason, $result, $newrefid) = $zc->Init
($user, 
> $password, $refid);
>
>               if (! $status) {
>                       $strError = "couldn't initialize the
association";
>               } elsif (! $result) {
>                       $strError = "target rejected request\n";
>
>               } else {
>
>                       #try to create a result set
>                       ($status, $reason, $found, $info)
>                               = $zc->Search ($database, $resultset,
$query, $attrsetid);
>
>                       if (! $status) {
>                               $strError = "couldn't create result
set\n";
>                       } elsif (! $found ) {
>
>                               #got no results so it's not here
>                               $strError = "no results";
>
>                       } else {
>
>                               # try to grab records from result set
>                               ($status,  $reason,  $returned,
> @records)
>                                       = $zc->Present ($resultset,
> $howmany,  $start,  $format,  $syntax);
>
>                               if (! $status) {
>                                       $strError = "couldn't process
> result set\n";
>                               } else {
>
>                                       #close the association
>                                       ($status, $reason) = $zc->Close
> ($close);
>
>                                       print "$returned\n";
>
>                                       #cycle thru results, printing to
> screen
>
>                                       foreach $data (@records) {
>
>                                               print $data;
>                                       }
>
>                               }
>                       }
>               }
>       }
>       print "$strError\n";
> }1;
>
> ================
>
> This prints to the screen:
>
> 1
> 1.2.840.10003.5.102&
>
> ============================
> David Walker
> Web Developer
> Library
> California State University, San Marcos
> ph: (760) 750-4379
> ============================

-- 
Ben Soares                                         tel: +44 (0)131-651
1238
EDINA, Edinburgh University Data Library           fax: +44 (0)131-650
3308
Main Library Building, George Square             email:
[EMAIL PROTECTED]
Edinburgh EH8 9LJ, Scotland, UK                    www:
http://edina.ac.uk/

"Hmmm, that makes no sense to me...
 But then you are very small, perhaps you're right." -- Treebeard

Reply via email to