Finished.
[idzebra-moved-to-github.git] / util / abs2dom
1 #!/usr/bin/perl -w
2
3 # $Id: abs2dom,v 1.2 2007-12-17 12:28:50 sondberg Exp $
4 # ----------------------------------------------------------------------------
5 # Generate a dom-filter indexing stylesheet based upon an .abs file
6
7 use strict;
8
9 print <<END_OF_XSLT;
10 <?xml version="1.0"?>
11 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12                     xmlns:z="http://indexdata.com/zebra-2.0"
13                     version="1.0">
14
15   <xsl:output indent="yes"
16         method="xml"
17         version="1.0"
18         encoding="UTF-8"/>
19
20   <xsl:template match="/">
21     <z:record>
22       <xsl:apply-templates/>
23     </z:record>
24   </xsl:template>
25
26 END_OF_XSLT
27
28
29 while (<>) {
30     chomp;
31     s/^\s+//;
32     s/\s+$//;
33     next unless s/^xelm\s+//;
34     my ($index) = (/(\S+)$/);
35     s/\s+\Q$index\E$//;
36     my $xpath = $_;
37     my @indexes = split /,/, $index;
38
39     print "  <xsl:template match=\"$xpath\">\n";
40     print "    <z:index name=\"", join(" ", @indexes), "\">\n";
41     print "      <xsl:value-of select=\".\"/>\n";
42     print "    </z:index>\n";
43     print "  </xsl:template>\n\n";
44 }
45
46
47 print "</xsl:stylesheet>\n";