On Nov 27, 2005, at 5:29 PM, [EMAIL PROTECTED] wrote:

The first cut at the explain information is at:
    http://search.halinet.on.ca/search/MarineImagesExplain.xml

A snippet of one version of the code that attempts to incorporate this
into the perl script (badly)
        $response = SRU::Response::Explain->new ($request);
        my $ExplainFile = get($ExplainXMLfile);
        $response = SRU::Response::Explain->record ($ExplainFile);

This yields a "must pass in a SRU::Response::Record Object" error
message on the last of these lines.


In my SRU server applications I hard code my Explain response like below, but because it is called as method from a package I can change the package and keep my code:


# require modules
use lib ".";
use CGI qw(-oldstyle_urls);
use explain;
use SRU::Request;
use SRU::Response;
use SRU::Response::Term;

# initlize the necessary objects
my $cgi      = CGI->new();
my $request  = SRU::Request->newFromCGI($cgi);
my $response = SRU::Response->newFromRequest($request);

# check for type of response
if ($response->type() eq 'explain') {

        # fill up the response's record
        $response->record(SRU::Response::Record->new(
                recordSchema => 'http://explain.z3950.org/dtd/2.0/',
                recordData => explain->record()));

}

#
# handle other responses here
#

# done; output the result
print $cgi->header('text/xml');
print $response->asXML(encoding=>"ISO-8859-1");
exit;


# explain.pm - simply build a hard-coded explain response
package explain;
use strict;

sub record {

        return <<EOF
<explain xmlns="http://explain.z3950.org/dtd/2.0/";>
        <serverInfo protocol='SRU' version='1.1'>
                <host>
                        mylibrary.ockham.org
                </host>
        <!-- hard code balance of explain response here -->
</explain>
EOF
}

# return true or else
1;


WFM.

--
Eric Morgan
University Libraries of Notre Dame

Reply via email to