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