]> matita.cs.unibo.it Git - helm.git/blob - helm/metadata/create2/invert.pl
MathQL homepage added
[helm.git] / helm / metadata / create2 / invert.pl
1 #!/usr/bin/perl
2
3 my $inputfile = $ARGV[0];
4
5 print "Now splitting file $inputfile\n";
6 open(IN, "<$inputfile") or die "Error opening file $inputfile";
7 $dummy = <IN>;  # <?xml version="1.0" encoding="ISO-8859-1"?>
8 $dummy = <IN>;  #
9 $dummy = <IN>;  # <rdf:RDF .../>
10 $where = <IN>;  # <h:Object rdf:about="...">
11 chomp($where);
12 $where =~ s/^[^"]*"([^"]*)">$/$1/;
13 while(($line1 = <IN>) && not ($line1 =~ /<\/h:Object>/)) {
14   $line2 = <IN>;
15   $line3 = <IN>; # </refObj>
16   $uri = $line2;
17   chomp($uri);
18   $uri =~ s/^ *<h:Occurrence rdf:about="[^"]*" rdf:value="([^"]*)"\/>$/$1/;
19   $who = $uri;
20   $who =~ s/^cic:/backward/;
21   $who =~ s/#xpointer\(1\/([^\/]*)\/([^\/]*)\)/,$1,$2/;
22   $who =~ s/#xpointer\(1\/([^\/]*)\)/,$1/;
23   $line2 =~ s/\Q$uri\E/$where/;
24    
25   open(OUT, ">>$who") or die "Error opening file $who";
26   print OUT "    <h:backPointer>\n";
27   print OUT $line2;
28   print OUT "    </h:backPointer>\n";
29   close(OUT);
30 }
31 close(IN);