Bug 10403: (follow-up) fix test to use vendor created earlier during test
[koha.git] / misc / maintenance / make_zebra_dom_cfg_from_record_abs
1 #!/usr/bin/perl
2
3 # Copyright (c) 2012 Equinox Software, Inc.
4 # This file is part of Koha.
5 #
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
10 #
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA  02111-1307 USA
18
19 use strict;
20 use warnings;
21 use 5.010;
22
23 use Koha::Indexer::Utils;
24
25 use Getopt::Long;
26
27 my $input_file;
28 my $output_file;
29 my $want_help;
30 my $result = GetOptions(
31     'input:s'      => \$input_file,
32     'output:s'     => \$output_file,
33     'help|h'       => \$want_help,
34 );
35
36 if ( not $result or $want_help or not defined $input_file or not defined $output_file ) {
37     print_usage();
38     exit 0;
39 }
40
41 open my $infh,  '<', $input_file or die "$0: cannot open input file $input_file: $!\n";
42 open my $outfh, '>', $output_file or die "$0: cannot open output file $output_file: $!\n";
43
44 my $grs1_cfg = join('', <$infh>);
45 close $infh;
46 my $dom_cfg = Koha::Indexer::Utils::zebra_record_abs_to_dom($grs1_cfg);
47 print $outfh $dom_cfg;
48 close $outfh;
49
50 sub print_usage {
51     print <<_USAGE_;
52 $0: generate a DOM filter Zebra index config from a GRS-1 config
53
54 Given a Zebra record.abs file containing a set of index definitions for
55 Zebra's GRS-1 filter, write an equivalent DOM filter configuration.
56
57 To generate the XSLT that is to be used by Zebra, run something like
58 the following on the output of this utility:
59
60 xsltproc ZEBRA_CFG_DIR/xsl/koha-indexdefs-to-zebra.xsl \\
61   biblio-koha-indexdefs.xml \\
62   > ZEBRA_CFG_DIR/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl
63
64 The above example assumes that the output of the program was named
65 biblio-koha-indexdefs.xsl.
66
67 Parameters:
68     --input                 input file name
69     --output                output file name
70     --help or -h            show this message
71 _USAGE_
72 }