SRU(3pm)
β¨ SRU β Search and Retrieval by URL β¨
okay bestie, welcome to SRU(3pm), a User Contributed Perl Documentation page, and honestly? it's giving library-science-girlboss. let's get into it π
πΈ NAME πΈ
SRU β Search and Retrieval by URL. that's it, that's the name, she's simple and she knows it π
π¦ SYNOPSIS π¦
## a simple CGI example
use SRU::Request;
use SRU::Response;
## create CGI object
my $cgi = CGI->new();
## create a SRU request object from the CGI object
my $request = SRU::Request->newFromCGI( $cgi );
## create a SRU response based from the request
my $response = SRU::Response->newFromRequest( $request );
if ( $response->type() eq 'explain' ) {
...
} elsif ( $response->type() eq 'scan' ) {
...
} elsif ( $response->type() eq 'searchRetrieve' ) {
...
}
## print out the response
print $cgi->header( -type => 'text/xml' );
print $response->asXML();
like, that's the whole vibe right there. make a request, make a response, check the type, print the XML. no cap. π₯
π DESCRIPTION π
so the SRU package is a whole framework for working with the Search and Retrieval by URL (SRU) protocol, which was developed by the Library of Congress. SRU defines a web service for searching databases that contain metadata and objects. and here's the tea: SRU often goes under the name SRW, which is a SOAP version of the protocol. so you can think of SRU as a RESTful version of SRW, because all the requests are simple URLs instead of XML documents being sent via some sort of transport layer. iconic behaviour honestly. π
you might be interested in SRU if you wanna provide a generic API for searching a data repository, plus a mechanism for returning metadata records. SRU defines three verbs: explain, scan and searchRetrieve, and those define the requests and responses in a SRU interaction. three verbs, three moods, one protocol. periodt. π
this set of modules is trying to provide a framework for building an SRU service. the distribution is made up of two sets of Perl modules:
- modules in the
SRU::Request::*namespace, which represent the three types of requests - modules in the
SRU::Response::*namespace, which represent the various responses
typical usage is that a request object gets created using a factory method in the SRU::Request module. the factory is given either a URI or a CGI object for the HTTP request, and SRU::Request will look at the URI and build the appropriate request object: SRU::Request::Explain, SRU::Request::Scan or SRU::Request::SearchRetrieve. it just knows. main character energy fr fr. β¨
once you've got a request object, you can build a response object by using the factory method newFromRequest() in SRU::Request. this method will examine the request and build the corresponding result object, which you can then populate with result data appropriately. and when you're done populating the response object with results, you can call asXML() on it to get the full XML for your response. slay. π
to understand the meaning of the various requests and their responses, you'll wanna read the docs at the Library of Congress. a good place to start is this simple introductory page: http://www.loc.gov/standards/sru/simple.html
for more info about working with the various request and response objects in this distribution, see the POD in the individual packages:
SRU::RequestSRU::Request::ExplainSRU::Request::ScanSRU::Request::SearchRetrieveSRU::ResponseSRU::Response::ExplainSRU::Response::ScanSRU::Response::SearchRetrieveSRU::Server
questions and comments are more than welcome π«Ά this software was developed as part of a National Science Foundation grant for building distributed library systems in the Ockham Project. more about Ockham can be found at http://www.ockham.org.
π DEPENDENCIES π
to use SRU::Server and Catalyst::Controller::SRU, one must install CGI::Application and Catalyst, respectively. (respectively!! matching them up correctly, we love to see it π
)
heads up bestie: in a future release Catalyst::Controller::SRU might be moved to an independent module. so like, don't get too attached to where it lives rn. π
π§ TODO π§
the wishlist, the vision board, the little dreams:
- create a client (
SRU::Client) - allow
searchRetrieveresponses to be retrieved as RSS - make sure
SRU::Servercan function like real-world SRU interfaces - handle CQL parsing errors
- better argument checking in response constructors
it's giving "we'll get to it" and honestly, same. π
π AUTHORS π
Ed Summers <ehs@pobox.com>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2013 by Ed Summers.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page bestie, you're officially SRU-pilled πΈ and one last thing before you go β this was brought to you by perl v5.34.0, dated 2022-06-17, filing under SRU(3pm). mwah, go build a web service π
β¨π¦
π¦ where this page comes from
- debian bookworm: libsru-perl 1.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsru-perl 1.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsru-perl 1.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsru-perl 1.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsru-perl 1.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms