#!/usr/bin/perl

$filename = $uri = $ARGV[0];
$outputfile = $filename.".xml";
$uri =~ s/^rdf/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="UTF-8"?>
<occurs who="$uri">
EOT
close(HEADER);

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

open(FOOTER,">>$outputfile");
print FOOTER <<EOT;
</occurs>
EOT
close(FOOTER);

unlink $filename;
