]> matita.cs.unibo.it Git - helm.git/blob - helm/metadata/create/split.pl
Initial revision
[helm.git] / helm / metadata / create / split.pl
1 #!/usr/bin/perl
2
3 foreach $inputfile (@ARGV) {
4  print "Now splitting file $inputfile\n";
5  open(IN, "<$inputfile");
6  while($line = <IN>) {
7   if (not ($line =~ /^<?xml/ || $line =~/^<(\/|)occurrences>/)) {
8    if ($line =~ /^<!--/) {
9     # Begin of a new output file
10     $line =~ s/^<!--(.*)-->$/$1/;
11     $line =~ s/^cic:/rdf/;
12     $line =~ s/#xpointer\(1\/([^\/]*)\/([^\/]*)\)/,$1,$2/;
13     $line =~ s/#xpointer\(1\/([^\/]*)\)/,$1/;
14     $dir = $line;
15     $dir =~ s/\/[^\/]*$//;
16     close(OUT);
17     system("mkdir -p $dir");
18     open(OUT, ">>$line");
19    } else {
20     print OUT $line;
21    }
22   }
23  }
24  close(IN);
25 }
26 close(OUT);