idzebra-abs2dom part of dist and packages
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 28 Jun 2011 15:15:52 +0000 (17:15 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 28 Jun 2011 15:15:52 +0000 (17:15 +0200)
Solves bug #2685.

debian/idzebra-2.0-utils.install
debian/idzebra-2.0-utils.manpages
doc/Makefile.am
doc/idzebra-abs2dom.xml [new file with mode: 0644]
idzebra.spec
util/Makefile.am
util/abs2dom [deleted file]
util/idzebra-abs2dom [new file with mode: 0755]

index d839031..396e623 100644 (file)
@@ -1,2 +1,3 @@
 usr/bin/zebraidx-2.0
 usr/bin/zebrasrv-2.0
+usr/bin/idzebra-abs2dom
index 3d268eb..aee27c4 100644 (file)
@@ -1,2 +1,3 @@
 doc/zebrasrv-2.0.8
 doc/zebraidx-2.0.1
+doc/idzebra-abs2dom.1
index 8d315ae..5473cae 100644 (file)
@@ -2,13 +2,14 @@ SUBDIRS = common
 
 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 \
@@ -57,6 +58,9 @@ idzebra-config$(PACKAGE_SUFFIX).1: idzebra-config.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
diff --git a/doc/idzebra-abs2dom.xml b/doc/idzebra-abs2dom.xml
new file mode 100644 (file)
index 0000000..3a711ae
--- /dev/null
@@ -0,0 +1,65 @@
+<!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:
+-->
index 426c51f..a624c9e 100644 (file)
@@ -72,9 +72,11 @@ rm -fr ${RPM_BUILD_ROOT}
 %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}
index 2a967b3..e7a1412 100644 (file)
@@ -5,7 +5,7 @@ check_PROGRAMS = tstcharmap tstflock tstlockscope tstpass tstres test_strmap
 
 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
 
diff --git a/util/abs2dom b/util/abs2dom
deleted file mode 100755 (executable)
index bfb77d9..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/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;
-}
-
-
-
diff --git a/util/idzebra-abs2dom b/util/idzebra-abs2dom
new file mode 100755 (executable)
index 0000000..464ca98
--- /dev/null
@@ -0,0 +1,124 @@
+#!/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;
+}
+
+
+