1 %# $Id: full.mc,v 1.19 2006-12-06 13:00:40 mike Exp $
6 my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1");
7 $conn->option(elementSetName => "zeerex");
10 my $query = qq[rec.id="$qid"];
11 my $rs = $conn->search(new ZOOM::Query::CQL($query));
14 $m->comp("/details/error.mc",
15 title => "Error", message => "No such ID '$id'");
17 my $xc = irspy_xpath_context($rs->record(0));
19 [ Name => "e:databaseInfo/e:title",
20 lang => "en", primary => "true" ],
21 [ Country => "i:status/i:country" ],
22 [ "Last Checked" => "i:status/i:probe[last()]" ],
23 [ Protocol => "e:serverInfo/\@protocol" ],
24 [ Host => "e:serverInfo/e:host" ],
25 [ Port => "e:serverInfo/e:port" ],
26 [ "Database Name" => "e:serverInfo/e:database" ],
27 [ "Type of Library" => "i:status/i:libraryType" ],
28 [ "Username (if needed)" =>
29 "e:serverInfo/e:authentication/e:user" ],
30 [ "Password (if needed)" =>
31 "e:serverInfo/e:authentication/e:password" ],
32 [ Description => "e:databaseInfo/e:description",
33 lang => "en", primary => "true" ],
34 [ Author => "e:databaseInfo/e:author" ],
35 [ Contact => "e:databaseInfo/e:contact" ],
36 [ "URL to Hosting Organisation" => "i:status/i:hostURL" ],
37 [ Extent => "e:databaseInfo/e:extent" ],
38 [ History => "e:databaseInfo/e:history" ],
39 [ "Language of Records" => "e:databaseInfo/e:langUsage" ],
40 [ Restrictions => "e:databaseInfo/e:restrictions" ],
41 [ Subjects => "e:databaseInfo/e:subjects" ],
42 [ "Implementation ID" => "i:status/i:implementationId" ],
43 [ "Implementation Name" => "i:status/i:implementationName" ],
44 [ "Implementation Version" => "i:status/i:implementationVersion" ],
45 [ "Reliability" => \&calc_reliability, $xc ],
46 [ "Services" => \&calc_init_options, $xc ],
47 [ "Bib-1 Use attributes" => \&calc_ap, $xc, "bib-1" ],
48 [ "Dan-1 Use attributes" => \&calc_ap, $xc, "dan-1" ],
49 [ "Operators" => \&calc_boolean, $xc ],
50 [ "Named Result Sets" => \&calc_nrs, $xc ],
51 [ "Record syntaxes" => \&calc_recsyn, $xc ],
52 [ "Explain" => \&calc_explain, $xc ],
55 <h2><% xml_encode($xc->find("e:databaseInfo/e:title"), "") %></h2>
56 <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
58 foreach my $ref (@fields) {
59 my($caption, $xpath, @args) = @$ref;
61 if (ref $xpath && ref($xpath) eq "CODE") {
62 $data = &$xpath(@args);
64 $data = $xc->find($xpath);
69 <th><% xml_encode($caption) %></th>
70 <td><% xml_encode($data) %></td>
78 sub calc_reliability {
81 my @allpings = $xc->findnodes("i:status/i:probe");
83 return "[untested]" if $nall == 0;
84 my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
86 return "$nok/$nall = " . int(100*$nok/$nall) . "%";
89 sub calc_init_options {
93 my @nodes = $xc->findnodes('e:configInfo/e:supports/@type');
94 foreach my $node (@nodes) {
95 my $type = $node->value();
96 if ($type =~ s/^z3950_//) {
101 return join(", ", @ops);
107 my $expr = 'e:indexInfo/e:index/e:map/e:attr[
108 @set = "'.$set.'" and @type = "1"]';
109 my @bib1nodes = $xc->findnodes($expr);
110 my $nbib1 = @bib1nodes;
111 return "[none]" if $nbib1 == 0;
115 @bib1nodes = sort { $a->findvalue(".") <=> $b->findvalue(".") } @bib1nodes;
116 foreach my $node (@bib1nodes) {
117 my $ap .= $node->findvalue(".");
118 if (!defined $first) {
120 } elsif (!defined $last || $last == $ap-1) {
123 # Got a complete range
124 $res .= ", " if $res ne "";
126 $res .= "-$last" if defined $last;
133 if (defined $first) {
134 $res .= ", " if $res ne "";
136 $res .= "-$last" if defined $last;
139 return "$nbib1 access points: $res";
145 ### Note that we are currently interrogating an IRSpy extension.
146 # The standard ZeeRex record should be extended with a
147 # "supports" type for this.
148 my @nodes = $xc->findnodes('i:status/i:boolean[@ok = "1"]');
149 my $res = join(", ", map { $_->findvalue('@operator') } @nodes);
150 $res = "[none]" if $res eq "";
157 my @nodes = $xc->findnodes('i:status/i:named_resultset[@ok = "1"]');
158 return @nodes ? "Yes" : "No";
164 my @nodes = $xc->findnodes('e:recordInfo/e:recordSyntax');
165 my $res = join(", ", map { $_->findvalue('@name') } @nodes);
166 $res = "[none]" if $res eq "";
173 my @nodes = $xc->findnodes('i:status/i:explain[@ok = "1"]');
174 my $res = join(", ", map { $_->findvalue('@category') } @nodes);
175 $res = "[none]" if $res eq "";