line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAX::Document; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
13
|
use YAX::Text; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
48
|
|
6
|
3
|
|
|
3
|
|
21
|
use YAX::Element; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
57
|
|
7
|
3
|
|
|
3
|
|
11
|
use YAX::Fragment; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
53
|
|
8
|
3
|
|
|
3
|
|
13
|
use YAX::Constants qw/:all/; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
584
|
|
9
|
3
|
|
|
3
|
|
18
|
use YAX::Query; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
131
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
14
|
use overload '@{}' => \&children, '%{}' => \&elements, fallback => 1; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
33
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub HASH () { 0 } |
14
|
|
|
|
|
|
|
sub KIDS () { 1 } |
15
|
|
|
|
|
|
|
#sub TYPE () { 3 } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
2
|
|
|
2
|
0
|
4
|
my $class = shift; |
19
|
2
|
|
|
|
|
8
|
my $self = bless \[ { }, [ ], '' ], $class; |
20
|
2
|
|
|
|
|
7
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
0
|
16
|
sub type { DOCUMENT_NODE } |
24
|
0
|
|
|
0
|
0
|
0
|
sub name { '#document' } |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
0
|
sub document { $_[0] } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub elements { |
29
|
10
|
|
|
10
|
0
|
183
|
my $self = shift; |
30
|
10
|
|
|
|
|
40
|
$$self->[HASH]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub children { |
34
|
22
|
|
|
22
|
0
|
37
|
my $self = shift; |
35
|
22
|
|
|
|
|
91
|
$$self->[KIDS]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
0
|
sub parent { undef } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#sub doctype { |
41
|
|
|
|
|
|
|
# my $self = shift; |
42
|
|
|
|
|
|
|
# $$self->[TYPE] = shift if @_; |
43
|
|
|
|
|
|
|
# $$self->[TYPE]; |
44
|
|
|
|
|
|
|
#} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub set { |
47
|
7
|
|
|
7
|
0
|
12
|
my ( $self, $id, $elmt ) = @_; |
48
|
7
|
|
|
|
|
19
|
$self->elements->{$id} = $elmt; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get { |
52
|
1
|
|
|
1
|
0
|
1
|
my ( $self, $id ) = @_; |
53
|
1
|
|
|
|
|
3
|
return $self->elements->{$id}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub root { |
57
|
3
|
|
|
3
|
0
|
944
|
my ( $self ) = @_; |
58
|
3
|
|
|
|
|
8
|
foreach my $node ( @$self ) { |
59
|
7
|
100
|
|
|
|
20
|
return $node if $node->type == ELEMENT_NODE; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
return undef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub text { |
65
|
0
|
|
|
0
|
0
|
|
my ( $self, $text ) = @_; |
66
|
0
|
|
|
|
|
|
my $node = YAX::Text->new( $text ); |
67
|
0
|
|
|
|
|
|
return $node; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub element { |
71
|
0
|
|
|
0
|
0
|
|
my ( $self, $name, %atts ) = @_; |
72
|
0
|
|
|
|
|
|
my $node = YAX::Element->new( $name, %atts ); |
73
|
0
|
|
|
|
|
|
return $node; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub fragment { |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
my $frag = YAX::Fragment->new(@_); |
79
|
0
|
|
|
|
|
|
return $frag; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*query = \&YAX::Element::query; |
83
|
|
|
|
|
|
|
*append = \&YAX::Element::append; |
84
|
|
|
|
|
|
|
*replace = \&YAX::Element::replace; |
85
|
|
|
|
|
|
|
*remove = \&YAX::Element::remove; |
86
|
|
|
|
|
|
|
*insert = \&YAX::Element::insert; |
87
|
|
|
|
|
|
|
*_claim_child = \&YAX::Element::_claim_child; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub as_string { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
my @kids = @{ $self->children }; |
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $kids = join('', map { $_->as_string } @{ $self->children }); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
join( '', $kids ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |