-# $Id: Utils.pm,v 1.27 2007-04-27 14:04:40 mike Exp $
+# $Id: Utils.pm,v 1.30 2007-05-02 13:52:54 mike Exp $
package ZOOM::IRSpy::Utils;
# a null transform; now we have to be a bit cleverer.
#
sub irspy_identifier2target {
+ my $res = _irspy_identifier2target(@_);
+ #carp "converted ID '@_' to target '$res'";
+ return $res;
+}
+
+sub _irspy_identifier2target {
my($id) = @_;
my($protocol, $target) = ($id =~ /(.*?):(.*)/);
- print STDERR "protocol='$protocol', target='$target'\n";
- ### This assumes everything is Z39.50
+ if (uc($protocol) eq "Z39.50") {
+ return "tcp:$target";
+ } elsif (uc($protocol) eq "SRU") {
+ return "sru=get,http:$target";
+ } elsif (uc($protocol) eq "SRW") {
+ return "sru=srw,http:$target";
+ }
+
+ warn "unrecognised protocol '$protocol' in ID $id";
return $target;
}
# we'll check whether the element is already
# canonical, to determine whether our change is a
# no-op.
- my $old = "???";
+ my $old = "";
my @children = $node->childNodes();
if (@children == 1) {
my $child = $node->firstChild();
if (ref $child && ref $child eq "XML::LibXML::Text") {
$old = $child->getData();
- next if $value eq $old;
}
}
+ next if $value eq $old;
$node->removeChildNodes();
my $child = new XML::LibXML::Text($value);
$node->appendChild($child);
push @changes, $ref;
- #print "Elem $key: '$old' -> '$value' ($xpath)<br/>\n";
+ print STDERR "Elem $key: '$old' -> '$value' ($xpath)<br/>\n";
} else {
warn "unexpected node type $node";
}