NAME
Keystone::Resolver - an OpenURL resolver
SYNOPSIS
use Keystone::Resolver;
$resolver = new Keystone::Resolver();
$openURL = $resolver->openURL($args, $base, $referer);
($type, $content) = $openURL->resolve();
print "Content-type: $type\r\n\r\n$content";
DESCRIPTION
This is the top-level class of Index Data's Keystone Resolver. It delegates the process of resolving OpenURLs to a swarm of worker classes.
METHODS
new()
$resolver = new Keystone::Resolver();
$resolver = new Keystone::Resolver(logprefix => "Keystone Resolver");
$resolver = new Keystone::Resolver(logprefix => "Keystone Resolver",
xsltdir => "/home/me/xslt");
Creates a new resolver that can be used to resolve OpenURLs. If arguments are provided, they are taken to be pairs that specify the names and values of options. See the documentation of the option()
method below for information about specific options.
One option is special to this constructor: if _rw
is provided and true, then the database is opened readwrite rather then readonly (which is the default).
The resolver object accumulates some state as it goes along, so it is generally more efficient to keep using a single resolver than to make new one every time you need to resolve an OpenURL.
option()
$level = $resolver->option("loglevel");
$oldpath = $resolver->option(xsltdir => "/home/me/xslt");
Gets and sets options in a Keystone::Resolver
object. When called with a single argument, returns the value the resolver has for that key. When called with two arguments, a key and a value, sets the specified new value for that key and returns the old value anyway.
Supported options include:
- logprefix
-
The initial string emitted at the beginning of each line of debugging output generated by the
log()
method. The default value is the name of the running program. - loglevel
-
A bit mask indicating the categories of message that should be logged by calls to the
log()
method. Should be set to the bitwise AND of zero or more of the symbolic constants defined inKeystone::Resolver::LogLevel
. See the documentation of that module for a description of the recognised categories. - xsltdir
-
The directory where the resolver looks for XSLT files.
log()
$resolver->log(Keystone::Resolver::LogLevel::CHITCHAT, "starting up");
Logs a message to thye standard error stream if the log-level of the resolver includes the level specified as the first argument in its bitmask. If so, the message consists of the logging prefix (by default the name of the program), the label of the specified level in parentheses, and all other arguments concatenated, finishing with a newline.
openURL()
$openURL = $resolver->openURL($args, $base, $referer);
Creates a new Keystone::Resolver::OpenURL
object using this Keystone::Resolver
and the specified arguments and referer. This is a shortcut for
new Keystone::Resolver::OpenURL($resolver, $args, $base, $referer)
parser()
$parser = $resolver->parser();
Returns the XML parser associated with this resolver. If it does not yet have a parser, then one is created for it, cached for next time, and returned. The parser is an XML::LibXML
object: see the documentation of that class for how to use it.
xslt()
$xslt = $resolver->xslt();
Returns the XSLT processor associated with this resolver. If it does not yet have a XSLT processor, then one is created for it, cached for next time, and returned. The XSLT processor is an XML::LibXSLT
object: see the documentation of that class for how to use it.
ua()
$ua = $resolver->ua();
Returns the LWP User Agent associated with this resolver. If it does not yet have a User Agent, then one is created for it, cached for next time, and returned.
stylesheet()
$stylesheet1 = $resolver->stylesheet();
$stylesheet2 = $resolver->stylesheet("foo");
Returns a stylesheet object for the XSLT stylesheet named in the argument, or for the default stylesheet if no argument is supplied. The returned object is an <XML::LibXSLT::Stylesheet>: see the documentation of that class for how to use it.
db()
$db = $resolver->db();
$db = $resolver->db("kr-backup");
Returns the database object associated with this specified name for this resolver. If no name is provided, the default name specified by the KRdb
environment variable is used; if this is also missing, "kr" is used. If the resolver does not yet have a database handle associated with this name, then one is created for it, cached for next time, and returned. The handle is a Keystone::Resolver::Database
object: see the documentation for how to use it.
AUTHOR
Mike Taylor <mike@indexdata.com>
First version Tuesday 9th March 2004.
SEE ALSO
Keystone::Resolver::OpenURL
, Keystone::Resolver::Result
, Keystone::Resolver::LogLevel
, Keystone::Resolver::ContextObject
, Keystone::Resolver::Database
, Keystone::Resolver::Descriptor
, Keystone::Resolver::Test
.