NAME
Library - Perl extension for Digital Library support
SYNOPSIS
use Library;
$a = mkdiglib($conf)
DESCRIPTION
Library::Simple uses Library::Thesaurus and a configuration file to manage digital libraries in a simple way. For this purpose, we define a digital library as a set of searchable catalogs and an ontology for that subject. Library::Simple configuration file has a list of catalogs with their respective parse information.
To this be possible, it should be some way to access any kind of catalog: a plain text file, XML document, SQL database or anything else. The only method possible is to define functions to convert these implementation techniques into a mathematical definition. So, the user should give four functions to this module to it be capable of use the catalog. These functions are:
- split the catalog
-
Given a string (say, a catalog identifier) the function should return a Perl array with all catalog entries. This array should be the same everytime the function is called for the same catalog to maintain some type of indexing. The function can use this string as a filename, a SQL table identifier or anything else the function can understand.
- terms for an entry
-
Given an entry with the format returned by the previous function, this function should return a list of terms related to the object catalogued by this entry. These terms will be used latter for thesaurus integration.
- html from the entry
-
Given an entry, return a piece of HTML code to be embebed when listing records.
- text from the entry
-
Given an entry, return the searchable text it includes.
The following example shows a sample configuration file:
$userconf = {
catalog => "/var/library/catalog.xml",
thesaurus => "/var/library/thesaurus",
navigate => "http://the.script.where.it/should/be/linked",
name => 'libraryName',
catsyn => {
1 => sub{ my $file=shift;
my $t=`cat $file`;
return ($t =~ m{(<entry.*?</entry>)}gs); },
2 => sub{ my $f=shift;
my @r=();
while($f =~ m{<rel\s+tipo='(.*?)'>(.*?)</rel>}g)
{ push @r, $2; }
@r; },
3 => sub{ my $f=shift; &mp::cat::fichacat2html($f)},
4 => sub{ my $f=shift;
$f =~ s{</?\w+}{ }g;
$f =~ s/(\s*[\n>"'])+\s*/,/g;
$f =~ s/\w+=//g;
$f =~ s/\s{2,}/ /g;
$f } } };
When using the mkdiglib
function with this configuration information, the module will create a set of files with cached data for quick response, inside a libraryName
directory. This function returns a Library object.
The configuration file can refer to more than one catalog file. This is done with the following syntax:
$userconf = {
thesaurus => "/var/library/thesaurus",
name => 'libraryName',
catalog => [
{ file => "/var/library/catalog.xml",
type => {
1 => sub{ ... },
2 => sub{ ... },
3 => sub{ ... },
4 => sub{ ... },
} },
{ file => ["/var/library/data1.db", "/var/library/data2.db"],
type => {
1 => sub{ ... },
2 => sub{ ... },
3 => sub{ ... },
4 => sub{ ... },
} }, ] }
After creating the object, we can open it on another script with the opendiglib
command wich receives the base name of the digital library. The base name is the path where it was created concatenated with the identifier used.
The most common way to use the digital library is to build a script like:
use Library::Simple;
use CGI qw/:standard :cgi-bin/;
my $library = "/var/library/libraryName";
my %vars = Vars();
print header;
my $diglib = Library::Simple::opendiglib( { name => $library } );
print $diglib->navigate(%vars);
AUTHOR
José João Almeida <jj@di.uminho.pt>
Alberto Simões <albie@alfarrabio.di.uminho.pt>
SEE ALSO
perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 565:
Non-ASCII character seen before =encoding in 'José'. Assuming CP1252