+ <h2>Statistics for <% xml_encode($stats->{host}) %></h2>
+ <h3><% $stats->{n} %> targets analysed
+ <% defined $query ? "for '" . xml_encode($query) . "'" : "" %></h3>
+% if ($from_cache) {
+ <p>Reusing cached result</p>
+% } else {
+ <p>Recalculating stats</p>
+% }
+<& table, stats => $stats, data => "bib1AccessPoints",
+ title => "The ten most commonly supported Bib-1 Use attributes",
+ headings => [ "Attribute", "Name"],
+ col3 => sub { bib1_access_point(@_) } &>
+<& table, stats => $stats, data => "recordSyntaxes",
+ title => "Record syntax support by database",
+ headings => [ "Record Syntax"] &>
+<& table, stats => $stats, data => "explain",
+ title => "Explain Support",
+ headings => [ "Explain Category"] &>
+<& table, stats => $stats, data => "z3950_init_opt",
+ title => "Z39.50 Protocol Services Support",
+ headings => [ "Service"] &>
+<& table, stats => $stats, data => "domains",
+ title => "Top Domains",
+ headings => [ "Top Domain"] &>
+%#
+%#
+<%def table>
+<%args>
+$stats
+$data
+$title
+@headings
+$col3 => undef
+</%args>
+ <h3><% $title %></h3>
+ <table border="1">
+ <thead>
+ <tr>
+% foreach my $heading ("#", @headings, "# Targets") {
+ <th><% xml_encode($heading) %></th>
+% }
+ </tr>
+ </thead>
+ <tbody>
+<%perl>
+my $hr;
+$hr = $stats->{$data};
+my @sorted = sort { $hr->{$b} <=> $hr->{$a} || $a <=> $b } keys %$hr;
+my $n = @sorted; $n = 10 if @sorted > 10;
+foreach my $i (1..$n) {
+ my $key = $sorted[$i-1];
+</%perl>
+ <tr>
+ <td><% $i %></td>
+ <td><% xml_encode($key, "HUH?") %></td>
+% if (defined $col3) {
+ <td><% xml_encode(&$col3($key), "HUH2?") %></td>
+% }
+ <td><% xml_encode($hr->{$key}, "HUH3?") . " (" .
+ int(10000*$hr->{$key}/$stats->{n})/100 . "%)" %></td>
+ </tr>
+% }
+ </tbody>
+ </table>
+</%def>