Solves bug #2685.
usr/bin/zebraidx-2.0
usr/bin/zebrasrv-2.0
+usr/bin/idzebra-abs2dom
doc/zebrasrv-2.0.8
doc/zebraidx-2.0.1
+doc/idzebra-abs2dom.1
docdir=$(datadir)/doc/$(PACKAGE)$(PACKAGE_SUFFIX)
-XMLMAN = zebraidx.xml zebrasrv.xml idzebra-config.xml
+XMLMAN = zebraidx.xml zebrasrv.xml idzebra-config.xml idzebra-abs2dom.xml
XMLFILES = \
administration.xml \
architecture.xml \
field-structure.xml \
gpl-2.0.xml \
+ idzebra-abs2dom.xml \
indexdata.xml \
installation.xml \
introduction.xml \
$(MAN_COMPILE) $(srcdir)/idzebra-config.xml
mv idzebra-config.1 idzebra-config$(PACKAGE_SUFFIX).1
+idzebra-abs2dom.1: idzebra-abs2dom.xml
+ $(MAN_COMPILE) $(srcdir)/idzebra-abs2dom.xml
+
$(HTMLFILES): $(XMLFILES) $(PNGFILES)
rm -f *.html
$(HTML_COMPILE) $(srcdir)/idzebra.xml
--- /dev/null
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.4//EN"
+ "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
+[
+ <!ENTITY % local SYSTEM "local.ent">
+ %local;
+ <!ENTITY % entities SYSTEM "entities.ent">
+ %entities;
+ <!ENTITY % idcommon SYSTEM "common/common.ent">
+ %idcommon;
+]>
+<refentry id="idzebra-abs2dom">
+ <refentryinfo>
+ <productname>zebra</productname>
+ <productnumber>&version;</productnumber>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>idzebra-abs2dom</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>idzebra-abs2dom</refname>
+ <refpurpose>Converts .abs files to DOM XML configuration files</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>idzebra-abs2dom</command>
+ <arg choice="opt"><replaceable>file</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1><title>DESCRIPTION</title>
+ <para>
+ <command>idzebra-abs2dom</command> converts grs filter .abs files
+ to DOM XML filter index XSLT files.
+ The melm and xelm directives are converted to XSLT rules. Conversion
+ of elm directives are not supported.
+ </para>
+ </refsect1>
+ <refsect1><title>SEE ALSO</title>
+ <para>
+ <citerefentry>
+ <refentrytitle>zebraidx</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+</refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-local-catalogs: nil
+sgml-namecase-general:t
+End:
+-->
%config /usr/share/idzebra-2.0/tab
%{_bindir}/zebrasrv-*
%{_bindir}/zebraidx-*
+%{_bindir}/idzebra-abs2dom*
/usr/share/doc/idzebra-2.0
%{_mandir}/*/zebraidx-*
%{_mandir}/*/zebrasrv-*
+%{_mandir}/*/idzebra-abs2dom*
/usr/share/idzebra-2.0-examples
%files -n lib%{name}
TESTS = $(check_PROGRAMS)
-bin_SCRIPTS = idzebra-config-2.0
+bin_SCRIPTS = idzebra-config-2.0 idzebra-abs2dom
EXTRA_DIST = zebrasrv.rh tstcharmap.chr emptycharmap.chr tstpass.txt tstres.cfg mk_version.tcl
+++ /dev/null
-#!/usr/bin/perl -w
-
-# ----------------------------------------------------------------------------
-# Generate a dom-filter indexing stylesheet based upon an .abs file
-# Should be called either this way
-#
-# abs2dom something.abs > something.xsl
-#
-# or in a streaming way
-#
-# something | abs2dom > something.xsl
-#
-# The output xslt stylesheet generally needs a little bit of tweaking to be
-# ready for indexing. In particular, watch out for the precedence rules of
-# xslt templates which work differently from xelm declarations in an .abs file!
-#
-# Good luck!
-
-use strict;
-
-my $marc_prefix = 'marc';
-my $supported_rules = {
-
- # Supported indexing types:
- 'melm' => \&melm_handler,
- 'xelm' => sub { return $_[1] },
-
- # Declarations to ignore:
- 'attset' => 0,
- 'encoding' => 0,
- 'esetname' => 0,
- 'marc' => 0,
- 'name' => 0,
- 'xpath' => 0
-
-};
-
-print <<END_OF_XSLT;
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:z="http://indexdata.com/zebra-2.0"
- xmlns:$marc_prefix="http://www.loc.gov/MARC21/slim"
- version="1.0">
-
- <xsl:output indent="yes"
- method="xml"
- version="1.0"
- encoding="UTF-8"/>
-
- <xsl:template match="/">
- <z:record>
- <xsl:apply-templates/>
- </z:record>
- </xsl:template>
-
-END_OF_XSLT
-
-
-while (<>) {
- my $handler = undef;
-
- chomp;
- s/^\s+//;
- s/\s+$//;
- next unless length;
- next if /^#/;
-
- my ($rule) = (/^(\S+)/);
-
- if ( defined $supported_rules->{$rule} ) {
- $handler = $supported_rules->{$rule};
-
- if ( $handler == 0 ) {
- next;
- }
- } else {
- print STDERR "$0: Unsupported indexing rule: '", $rule, "\n\n";
- next;
- }
-
- s/^\Q$rule\E\s+//;
-
- my ($index) = (/(\S+)$/);
-
- s/\s+\Q$index\E$//;
-
- my $match = $_;
- my $xpath = $handler->($rule, $match);
- my @indexes = split /,/, $index;
-
- # To avoid screwing up the <xsl:template match="...."> instruction...
- $xpath =~ s/"/'/g;
-
- print " <xsl:template match=\"$xpath\">\n";
- print " <z:index name=\"", join(" ", @indexes), "\">\n";
- print " <xsl:value-of select=\".\"/>\n";
- print " </z:index>\n";
- print " </xsl:template>\n\n";
-}
-
-print "</xsl:stylesheet>\n";
-
-
-sub melm_handler {
- my ($rule, $match) = @_;
- my ($field, $subfield) = ($match =~ /([^\$]+)\$?(.*)/);
- my $xpath = '/*/';
-
- if ( $field =~ /^00/ ) {
- $xpath .= $marc_prefix . ':controlfield[@tag=\'' . $field . '\']';
- } else {
- $xpath .= $marc_prefix . ':datafield[@tag=\'' . $field . '\']/' .
- $marc_prefix . ':subfield';
-
- if ( $subfield ne '' ) {
- $xpath .= '[@code=\'' . $subfield . '\']';
- }
- }
-
- return $xpath;
-}
-
-
-
--- /dev/null
+#!/usr/bin/perl -w
+
+# ----------------------------------------------------------------------------
+# Generate a dom-filter indexing stylesheet based upon an .abs file
+# Should be called either this way
+#
+# idzebra-abs2dom something.abs > something.xsl
+#
+# or in a streaming way
+#
+# something | idzebra-abs2dom > something.xsl
+#
+# The output xslt stylesheet generally needs a little bit of tweaking to be
+# ready for indexing. In particular, watch out for the precedence rules of
+# xslt templates which work differently from xelm declarations in an .abs file!
+#
+# Good luck!
+
+use strict;
+
+my $marc_prefix = 'marc';
+my $supported_rules = {
+
+ # Supported indexing types:
+ 'melm' => \&melm_handler,
+ 'xelm' => sub { return $_[1] },
+
+ # Declarations to ignore:
+ 'attset' => 0,
+ 'encoding' => 0,
+ 'esetname' => 0,
+ 'marc' => 0,
+ 'name' => 0,
+ 'xpath' => 0
+
+};
+
+print <<END_OF_XSLT;
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:z="http://indexdata.com/zebra-2.0"
+ xmlns:$marc_prefix="http://www.loc.gov/MARC21/slim"
+ version="1.0">
+
+ <xsl:output indent="yes"
+ method="xml"
+ version="1.0"
+ encoding="UTF-8"/>
+
+ <xsl:template match="/">
+ <z:record>
+ <xsl:apply-templates/>
+ </z:record>
+ </xsl:template>
+
+END_OF_XSLT
+
+
+while (<>) {
+ my $handler = undef;
+
+ chomp;
+ s/^\s+//;
+ s/\s+$//;
+ next unless length;
+ next if /^#/;
+
+ my ($rule) = (/^(\S+)/);
+
+ if ( defined $supported_rules->{$rule} ) {
+ $handler = $supported_rules->{$rule};
+
+ if ( $handler == 0 ) {
+ next;
+ }
+ } else {
+ print STDERR "$0: Unsupported indexing rule: '", $rule, "\n\n";
+ next;
+ }
+
+ s/^\Q$rule\E\s+//;
+
+ my ($index) = (/(\S+)$/);
+
+ s/\s+\Q$index\E$//;
+
+ my $match = $_;
+ my $xpath = $handler->($rule, $match);
+ my @indexes = split /,/, $index;
+
+ # To avoid screwing up the <xsl:template match="...."> instruction...
+ $xpath =~ s/"/'/g;
+
+ print " <xsl:template match=\"$xpath\">\n";
+ print " <z:index name=\"", join(" ", @indexes), "\">\n";
+ print " <xsl:value-of select=\".\"/>\n";
+ print " </z:index>\n";
+ print " </xsl:template>\n\n";
+}
+
+print "</xsl:stylesheet>\n";
+
+
+sub melm_handler {
+ my ($rule, $match) = @_;
+ my ($field, $subfield) = ($match =~ /([^\$]+)\$?(.*)/);
+ my $xpath = '/*/';
+
+ if ( $field =~ /^00/ ) {
+ $xpath .= $marc_prefix . ':controlfield[@tag=\'' . $field . '\']';
+ } else {
+ $xpath .= $marc_prefix . ':datafield[@tag=\'' . $field . '\']/' .
+ $marc_prefix . ':subfield';
+
+ if ( $subfield ne '' ) {
+ $xpath .= '[@code=\'' . $subfield . '\']';
+ }
+ }
+
+ return $xpath;
+}
+
+
+