Record contains a DOM tree of the ZeeRex record, not the text.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Record.pm
1 # $Id: Record.pm,v 1.4 2006-07-18 11:09:51 mike Exp $
2
3 package ZOOM::IRSpy::Record;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 use XML::LibXML;
10
11
12 =head1 NAME
13
14 ZOOM::IRSpy::Record - record describing a target for IRSpy
15
16 =head1 SYNOPSIS
17
18  ### To follow
19
20 =head1 DESCRIPTION
21
22 I<### To follow>
23
24 =cut
25
26 sub new {
27     my $class = shift();
28     my($target, $zeerex) = @_;
29
30     if (!defined $zeerex) {
31         $zeerex = _empty_zeerex_record($target);
32     }
33
34     my $parser = new XML::LibXML();
35     return bless {
36         target => $target,
37         zeerex => $parser->parse_string($zeerex),
38     }, $class;
39 }
40
41
42 sub _empty_zeerex_record {
43     my($target) = @_;
44
45     ### Doesn't recognise SRU/SRW URLs
46     my($host, $port, $db) = ZOOM::IRSpy::_parse_target_string($target);
47
48     return <<__EOT__;
49 <explain xmlns="http://explain.z3950.org/dtd/2.0/">
50  <serverInfo protocol="Z39.50" version="1995">
51   <host>$host</host>
52   <port>$port</port>
53   <database>$db</database>
54  </serverInfo>
55 </explain>
56 __EOT__
57 }
58
59
60 =head1 SEE ALSO
61
62 ZOOM::IRSpy
63
64 =head1 AUTHOR
65
66 Mike Taylor, E<lt>mike@indexdata.comE<gt>
67
68 =head1 COPYRIGHT AND LICENSE
69
70 Copyright (C) 2006 by Index Data ApS.
71
72 This library is free software; you can redistribute it and/or modify
73 it under the same terms as Perl itself, either Perl version 5.8.7 or,
74 at your option, any later version of Perl 5 you may have available.
75
76 =cut
77
78 1;