Remove extraneous and misleading old CVS IDs
[ZOOM-Perl-moved-to-github.git] / samples / zoom / zoomdump
1 #!/usr/bin/perl -w
2
3 # Dumps the contents of the nominated Zebra database to a set of
4 # separate XML files with numeric names.
5
6 use strict;
7 use warnings;
8 use ZOOM;
9
10 if (@ARGV != 1) {
11     print STDERR "Usage: $0 target\n";
12     exit 1;
13 }
14
15 my $conn = new ZOOM::Connection($ARGV[0]);
16 $conn->option(preferredRecordSyntax => "xml");
17 $conn->option(elementSetName => "zebra::data");
18 my $rs = $conn->search_pqf('@attr 1=_ALLRECORDS @attr 2=103 ""');
19 my $n = $rs->size();
20 $| = 1;
21 print "$0: dumping $n records\n";
22 foreach my $i (1..$n) {
23     print ".";
24     print " $i/$n (", int($i*100/$n), "%)\n" if $i % 50 == 0;
25     my $rec = $rs->record($i-1);
26     my $xml = $rec->render();
27     open F, ">$i.xml" or die "can't open\n";
28     print F $xml;
29     close F;
30 }
31 print " $n/$n (100%)\n" if $n % 50 != 0;