From 2fd21300f5864e9c9959603165218a7721147baa Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 16 Dec 2010 17:35:34 +0000 Subject: [PATCH] New --- bin/irspy-delete-broken-records.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 bin/irspy-delete-broken-records.pl diff --git a/bin/irspy-delete-broken-records.pl b/bin/irspy-delete-broken-records.pl new file mode 100755 index 0000000..38d772a --- /dev/null +++ b/bin/irspy-delete-broken-records.pl @@ -0,0 +1,28 @@ +#!/opt/local/bin/perl +# +# ./irspy-delete-broken-records.pl user=admin,password=fruitbat,localhost:8018/IR-Explain---1 'concat(count(irspy:status/irspy:probe[@ok=1]), "/", count(irspy:status/irspy:probe))' + +use lib '../lib'; +use XML::LibXML; +use ZOOM; +use strict; +use warnings; + +die "Usage: $0 \n" if @ARGV != 2; +my($dbname, $xpath) = @ARGV; + +my $libxml = new XML::LibXML; +my $conn = new ZOOM::Connection($dbname); +my $rs = $conn->search(new ZOOM::Query::CQL("cql.allRecords=1")); +$rs->option(elementSetName => "zeerex"); + +my $n = $rs->size(); +foreach my $i (1 .. $n) { + my $xml = $rs->record($i-1)->render(); + my $rec = $libxml->parse_string($xml)->documentElement(); + my $xc = XML::LibXML::XPathContext->new($rec); + $xc->registerNs(zeerex => "http://explain.z3950.org/dtd/2.0/"); + $xc->registerNs(irspy => "http://indexdata.com/irspy/1.0"); + my $val = $xc->findvalue($xpath); + print "Record $i/$n: $val\n"; +} -- 1.7.10.4