I'm going to break a personal rule and leave most of the rest of this
thread attached at the bottom for those who missed it as they returned
to work on Monday.
Eric's solution, to hard code an explain package for each SRU
application, was one I'm willing to implement, unless someone has an
equally brilliant way of doing it within Ed and Brian's framework.
What *is* SRU::Response::Explain->record () expecting?
Walter Lewis
(longing to explain himself)
Eric Lease Morgan wrote:
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.