package Copy;{
use Tree::Transform::XSLTish;
use Tree::Template::Declare;
use strict;
use warnings;
tree_rule match => '/', action => sub {
tree {
$_[0]->apply_rules;
};
};
tree_rule match => '*', priority => 0, action => sub {
node {
name $_[0]->it->name;
attribs %{$_[0]->it->attributes};
$_[0]->apply_rules;
};
};
}
package main;
use Test::Most 'no_plan','die';
use strict;
use warnings;
use Tree::Template::Declare;
use Data::Dumper;
sub Tree::DAG_Node::XPath::Root::xpath_get_root_node { return $_[0] }
sub Tree::DAG_Node::XPath::Root::xpath_get_parent_node { return }
my $tree=tree {
node {
name 'root';
attribs name => 'none';
node {
name 'coso1';
attribs name => 'coso_1';
};
node {
name 'coso2';
node {
name 'coso3';
};
};
};
};
diag "transforming";
my $trans=Copy->new();
my ($tree2)=$trans->transform($tree);
diag "comparing";
is($tree->tree_to_lol_notation(),
$tree2->tree_to_lol_notation(),
'tree copy');