allow to set xslt sheet on commandline
[irspy-moved-to-github.git] / bin / irspy-rewrite-records.pl
1 #!/usr/bin/perl
2
3 # perl -I ../lib irspy-rewrite-records.pl localhost:8018/IR-Explain---1
4
5 use strict;
6 use warnings;
7 use ZOOM::IRSpy;
8 use ZOOM::IRSpy::Utils qw(render_record);
9
10 my($dbname) = @ARGV;
11 die "$0 no database name specified" if !defined $dbname;
12
13 my $irspy_to_zeerex_xsl = $ARGV[1] || '../xsl/irspy2zeerex.xsl';
14
15 $ZOOM::IRSpy::irspy_to_zeerex_xsl = $irspy_to_zeerex_xsl
16   if $irspy_to_zeerex_xsl;
17
18 my $spy = new ZOOM::IRSpy($dbname, "admin", "fruitbat");
19 my $rs = $spy->{conn}->search(new ZOOM::Query::CQL("cql.allRecords=1"));
20 print STDERR "rewriting ", $rs->size(), " target records";
21
22 foreach my $i (1 .. $rs->size()) {
23     my $xml = render_record($rs, $i-1, "zeerex");
24     my $rec = $spy->{libxml}->parse_string($xml)->documentElement();
25     ZOOM::IRSpy::_rewrite_zeerex_record($spy->{conn}, $rec);
26     print STDERR ".";
27 }
28 print STDERR "\nDone\n";