1 # $Id: Record.pm,v 1.6 2006-07-21 16:50:20 mike Exp $
3 package ZOOM::IRSpy::Record;
10 use XML::LibXML::XPathContext;
15 ZOOM::IRSpy::Record - record describing a target for IRSpy
29 my($target, $zeerex) = @_;
31 if (!defined $zeerex) {
32 $zeerex = _empty_zeerex_record($target);
35 my $parser = new XML::LibXML();
38 zeerex => $parser->parse_string($zeerex)->documentElement(),
43 sub _empty_zeerex_record {
46 ### Doesn't recognise SRU/SRW URLs
47 my($host, $port, $db) = ZOOM::IRSpy::_parse_target_string($target);
50 <explain xmlns="http://explain.z3950.org/dtd/2.0/">
51 <serverInfo protocol="Z39.50" version="1995">
54 <database>$db</database>
63 my($xpath, $frag) = @_;
65 print STDERR "this=$this, xpath='$xpath', frag='$frag'\n";
66 my $root = $this->{zeerex}; # XML::LibXML::Element ISA XML::LibXML::Node
67 print "Record='", $root->toString(), "'\n";
68 my $xc = XML::LibXML::XPathContext->new($root);
69 $xc->registerNs(zeerex => "http://explain.z3950.org/dtd/2.0/");
70 $xc->registerNs(irspy => "http://indexdata.com/irspy/1.0");
72 my @nodes = $xc->findnodes($xpath);
74 ZOOM::Log::log("irspy", "no matches for '$xpath': can't append");
76 } elsif (@nodes > 1) {
77 ZOOM::Log::log("irspy", scalar(@nodes),
78 " matches for '$xpath': using first");
81 print STDERR "zeerex='$root'\n";
91 Mike Taylor, E<lt>mike@indexdata.comE<gt>
93 =head1 COPYRIGHT AND LICENSE
95 Copyright (C) 2006 by Index Data ApS.
97 This library is free software; you can redistribute it and/or modify
98 it under the same terms as Perl itself, either Perl version 5.8.7 or,
99 at your option, any later version of Perl 5 you may have available.