projects
/
ZOOM-Perl-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bf137ec
)
Rewritten. Now works properly.
author
mike
<mike>
Wed, 7 Mar 2007 11:34:26 +0000
(11:34 +0000)
committer
mike
<mike>
Wed, 7 Mar 2007 11:34:26 +0000
(11:34 +0000)
samples/zoom/zoomdump
patch
|
blob
|
history
diff --git
a/samples/zoom/zoomdump
b/samples/zoom/zoomdump
index
5e43615
..
c4fd65d
100755
(executable)
--- a/
samples/zoom/zoomdump
+++ b/
samples/zoom/zoomdump
@@
-1,7
+1,33
@@
#!/usr/bin/perl -w
#!/usr/bin/perl -w
+
+# $Id: zoomdump,v 1.2 2007-03-07 11:34:26 mike Exp $
+#
+# Dumps the contents of the nominated Zebra database to a set of
+# separate XML files with numeric names.
+
+use strict;
+use warnings;
use ZOOM;
use ZOOM;
-my $target = $ARGV[0];
-my $conn = new ZOOM::Connection($target);
+
+if (@ARGV != 1) {
+ print STDERR "Usage: $0 target\n";
+ exit 1;
+}
+
+my $conn = new ZOOM::Connection($ARGV[0]);
+$conn->option(preferredRecordSyntax => "xml");
+$conn->option(elementSetName => "zebra::data");
my $rs = $conn->search_pqf('@attr 1=_ALLRECORDS @attr 2=103 ""');
my $n = $rs->size();
my $rs = $conn->search_pqf('@attr 1=_ALLRECORDS @attr 2=103 ""');
my $n = $rs->size();
-print STDERR "$0: found $n records in '$target'\n";
+$| = 1;
+print "$0: dumping $n records\n";
+foreach my $i (1..$n) {
+ print ".";
+ print " $i/$n (", int($i*100/$n), "%)\n" if $i % 50 == 0;
+ my $rec = $rs->record($i-1);
+ my $xml = $rec->render();
+ open F, ">$i.xml" or die "can't open\n";
+ print F $xml;
+ close F;
+}
+print " $n/$n (100%)\n" if $n % 50 != 0;