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

# This is the simple 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 {
		  my ($q,$c,%v) = @_;
		  $c = "<prefix>prefixed </prefix>$c";
		  toxml
		},
		duplicate => sub {
		  my ($q,$c,%v) = @_;
		  toxml.toxml
		},
		change_tag => sub {
		  my ($q,$c,%v) = @_;
		  $q = 'new_tag';
		  toxml
		},
		erase => sub {
		  my ($q,$c) = @_;
		  $c
		},
		add_att => sub {
		  my ($q,$c,%v) = @_;
		  $v{new_att} = "foo";
		  toxml
		}
	       );

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