#!/usr/bin/perl -w
use strict;
use XML::DT;
#use simple_benchmark; # to get memory size

# This is the pornographic version

use Getopt::Long;

my( $in_file, $print);
GetOptions( 'print!' => \$print, 'in_file=s' =>\$in_file);
$in_file ||= 'test.xml';
$print= 1 unless( defined $print);

my %commands = ( delete => sub { "" },
		 prefix => sub { $c = "<prefix>prefixed </prefix>$c"; toxml },
		 duplicate => sub { toxml.toxml },
		 change_tag => sub { $q = 'new_tag'; toxml },
		 erase => sub { $c },
		 add_att => sub { $v{new_att} = "foo"; toxml }
	       );

my $result = pathdt($in_file,
		    '//process[@action]' => sub {
		      &{commands{$v{action}}}()
		    });
print $result if $print;