+<%perl>
+
+sub calc_reliability_wrapper {
+ my($id, $xc) = @_;
+ return calc_reliability_string($xc);
+}
+
+sub calc_init_options {
+ my($id, $xc) = @_;
+
+ my @ops;
+ my @nodes = $xc->findnodes('e:configInfo/e:supports/@type');
+ foreach my $node (@nodes) {
+ my $type = $node->value();
+ if ($type =~ s/^z3950_//) {
+ push @ops, $type;
+ }
+ }
+
+ return join(", ", @ops);
+}
+
+sub calc_ap {
+ my($id, $xc, $set) = @_;
+
+ my @aps = _list_ap($xc, $set);
+ my $n = @aps;
+ return "[none]" if $n == 0;
+
+ my $res = "";
+ my($first, $last);
+ foreach my $ap (@aps) {
+ if (!defined $first) {
+ $first = $last = $ap;
+ } elsif ($ap == $last+1) {
+ $last++;
+ } else {
+ # Got a complete range
+ $res .= ", " if $res ne "";
+ $res .= "$first";
+ $res .= "-$last" if $last > $first;
+ $first = $last = $ap;
+ }
+ }
+
+ # Leftovers
+ if (defined $first) {
+ $res .= ", " if $res ne "";
+ $res .= "$first";
+ $res .= "-$last" if $last > $first;
+ }
+
+ return ("$n access points: $res",
+ "/ap.html?id=$id&set=$set");
+}
+
+sub _list_ap {
+ my($xc, $set) = @_;
+
+ my $expr = 'e:indexInfo/e:index[@search = "true"]/e:map/e:attr[
+ @set = "'.$set.'" and @type = "1"]';
+ my @nodes = $xc->findnodes($expr);
+ return sort { $a <=> $b } map { $_->findvalue(".") } @nodes;
+}
+
+sub calc_bath {
+ my($id, $xc) = @_;
+
+ my @nodes = $xc->findnodes('i:status/i:search_bath[@ok = "1"]');
+ my $res = join(", ", map { $_->findvalue('@name') } @nodes);
+ $res = "[none]" if $res eq "";
+ return $res;
+}
+
+sub calc_boolean {
+ my($id, $xc) = @_;
+
+ ### Note that we are currently interrogating an IRSpy extension.
+ # The standard ZeeRex record should be extended with a
+ # "supports" type for this.
+ my @nodes = $xc->findnodes('i:status/i:boolean[@ok = "1"]');
+ my $res = join(", ", map { $_->findvalue('@operator') } @nodes);
+ $res = "[none]" if $res eq "";
+ return $res;
+}
+
+sub calc_nrs { _calc_boolean(@_, 'i:status/i:named_resultset[@ok = "1"]') }
+sub calc_mor { _calc_boolean(@_, 'i:status/i:multiple_opac[@ok = "1"]') }
+sub calc_piggyback { _calc_boolean(@_, 'i:status/i:piggyback[@ok = "1"]') }
+
+sub _calc_boolean {
+ my($id, $xc, $xpath) = @_;
+
+ my @nodes = $xc->findnodes($xpath);
+ return @nodes ? "Yes" : "No";
+}
+
+sub calc_recsyn {
+ my($id, $xc, $sep) = @_;
+ $sep = ", " if !defined $sep;
+
+ my @nodes = $xc->findnodes('e:recordInfo/e:recordSyntax');
+ my $res = join($sep, map { $_->findvalue('@name') } @nodes);
+ $res = "[none]" if $res eq "";
+ return $res;
+}
+
+sub calc_explain {
+ my($id, $xc) = @_;
+
+ my @nodes = $xc->findnodes('i:status/i:explain[@ok = "1"]');
+ my $res = join(", ", map { $_->findvalue('@category') } @nodes);
+ $res = "[none]" if $res eq "";
+ return $res;
+}
+</%perl>