summaryrefslogtreecommitdiff
path: root/t/02-xslt.t
blob: 0870716b7ac05b5b453f8ffa84c6fa872c10ac9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!perl 
 
package Copy;{ 
use Tree::Transform::XSLTish;
use Tree::Template::Declare;
use strict;
use warnings;
 
tree_rule match => '/'action => sub {
    my $t=$_[0];
    tree {
        $t->apply_rules;
    };
};
 
tree_rule match => '*'priority => 0, action => sub {
    my $t=$_[0];
    node {
        name $t->it->name;
        attribs %{$t->it->attributes};
        $t->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');