Log XML2/XSLT errors to yaz_log
[idzebra-moved-to-github.git] / test / dmoz / con2.pl
1 #!/usr/bin/perl -w
2
3 my $state = 'init';
4 my $topic = '';
5 my $title;
6 my $description;
7
8 my $no = 0;
9
10 while ($_ = <STDIN>) {
11     if (/<Topic r:id=\"(.*?)\">/) {
12         $topic = $1;
13     }
14     elsif (/<ExternalPage about=\"(.*?)\">/) {
15         $url = $1;
16     }
17     elsif (/<d:Title>(.*?)<\/d:Title>/) {
18         $title = $1;
19     }
20     elsif (/<d:Description>(.*?)<\/d:Description>/) {
21         $description = $1;
22     }
23     elsif (/<\/ExternalPage>/) {
24         if (($no % 30000) == 0) {
25             if ($no) {
26                  close(XO);
27             }
28             open(XO, ">dmoz." . ($no / 30000) . ".xml");
29         }
30         print XO "<meta>\n";
31         print XO " <title>$title</title>\n";
32         print XO " <description>$description</description>\n";
33         print XO " <url>$url</url>\n";
34         print XO " <topic>$topic</topic>\n";
35         print XO "</meta>\n";
36         $no++;
37     }
38 }
39 if ($no != 0) {
40     close(XO);
41 }