]> matita.cs.unibo.it Git - helm.git/blob - helm/metadata/postgresql_V7_mowgli/upload_sort.pl
Initial revision
[helm.git] / helm / metadata / postgresql_V7_mowgli / upload_sort.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 while(($skip = <IN>) && not ($skip =~ /<rdf:RDF/)) {}
8 while(($line0 = <IN>) && not ($line0 =~ /<\/rdf:RDF>/)) { # <h:Object
9   chomp($line0);
10   $line0 =~ s/^[^"]*"([^"]*)">$/$1/;
11   $line1 = <IN>; #<h:refRel..
12   $obj = $line1;
13   $line2 = <IN>; # <h:position rdf:resource="&hns;value"/>
14   $position = $line2;
15   chomp($position);
16   $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
17   $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position";
18   $line3 = <IN>;#<h:sort..
19   $sort = $line3; 
20   chomp($sort);
21   $sort =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
22   $sort = "http://www.cs.unibo.it/helm/schemas/schema-helm#$sort";
23   $line4 = <IN>; #<h:depth..
24   $depth = $line4;
25   chomp($depth);
26   $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
27   $line5 = <IN>; # </h:refRel
28   $line6 = <IN>; # </h:Object>
29    
30   $line0 =~ s/'/\\'/g; 
31   $position =~ s/'/\\'/g;
32   $depth =~ s/'/\\'/g;
33   $sort =~ s/'/\\'/g;
34   print "insert into hrefSort values ('$line0', '$position', '$sort', $depth);\n\n";
35 }
36 close(IN);