#!/usr/bin/perl

use XML::Twig;
if (!@ARGV) {
    @ARGV = "-";
}
foreach (@ARGV) {
  my $twig=XML::Twig->new(twig_handlers => {
        '_all_' => sub {
            if($_->gi =~ "svg:"){
                my $gi = $_->gi;
                $gi =~ s/^svg://;
                $_->set_gi($gi); 
                }
            
        },
        'i:pgf' => sub {
            $_->delete;
        },
        'i:pgfRef' => sub {
            $_->delete;
        },
        'x:xmpmeta' => sub {
            $_->delete;
        },
        'xpacket' => sub {
            $_->delete;
        }
           
    }
  
  );    # create the twig
  $twig->parsefile($_);        # build it
  open OUTFILE,  "> $_" or die "Can't open $_ : $!";
  $twig->flush (\*OUTFILE);                 # output the twig
  close OUTFILE;
}
