]> matita.cs.unibo.it Git - helm.git/blob - helm/metadata/postgresql_V7_mowgli/upload_rel.pl
Initial revision
[helm.git] / helm / metadata / postgresql_V7_mowgli / upload_rel.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:depth..
19   $depth = $line3;
20   chomp($depth);
21   $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
22   $line4 = <IN>; # </h:refRel
23   $line5 = <IN>; # </h:Object>
24    
25   $line0 =~ s/'/\\'/g; 
26   $position =~ s/'/\\'/g;
27   $depth =~ s/'/\\'/g;
28   print "insert into hrefRel values ('$line0', '$position', $depth);\n\n";
29 }
30 close(IN);