package BasicTransform;{
use Tree::Transform;
use strict;
use warnings;
tree_rule match => '/', action => sub {
return 'root', $_[0]->apply_rules;
};
tree_rule match => '*', action => sub {
return $_[0]->it->name, $_[0]->apply_rules;
}
}
package main;
use Test::Most qw(no_plan die);
use strict;
use warnings;
use Tree::DAG_Node::XPath;
sub Tree::DAG_Node::XPath::Root::xpath_get_root_node { return $_[0] }
my $tree=Tree::DAG_Node::XPath->new();
$tree->name('base');
$tree->new_daughter->name("coso$_") for 1..5;
my $trans=BasicTransform->new();
my @results=$trans->transform($tree);
is_deeply \@results,[qw(root base coso1 coso2 coso3 coso4 coso5)];