#!/usr/bin/perl

$filename = $uri = $ARGV[0];
$outputfile = $filename.".xml";
$uri =~ s/^backward/cic:/;
$uri =~ s/(.*),([^,]*),([^,]*)/$1#xpointer(1\/$2\/$3)/;
$uri =~ s/(.*),([^,]*)/$1#xpointer(1\/$2)/;

print "Now processing file $filename\n";

open(HEADER,">>$outputfile");
print HEADER <<EOT;
<?xml version="1.0" encoding="ISO-8859-1"?>

<rdf:RDF xml:lang="en" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:h="http://www.cs.unibo.it/helm/schemas/schema-h.rdf#">
  <h:Object rdf:about="$uri">
EOT
close(HEADER);

system("cat $filename >> $outputfile");

open(FOOTER,">>$outputfile");
print FOOTER <<EOT;
  </h:Object>
</rdf:RDF>
EOT
close(FOOTER);

unlink $filename;
