| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Toolkit::Loader::Filter; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$XML::Toolkit::Loader::Filter::VERSION = '0.15'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
2
|
|
|
2
|
|
3706
|
use Moose; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
19
|
|
|
6
|
2
|
|
|
2
|
|
14643
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends qw(XML::Filter::Moose); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw(XML::Toolkit::Builder::ClassRegistry); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has objects => ( |
|
13
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
traits => ['Array'], |
|
16
|
|
|
|
|
|
|
lazy => 1, |
|
17
|
|
|
|
|
|
|
builder => '_build_objects', |
|
18
|
|
|
|
|
|
|
clearer => 'reset_state', |
|
19
|
|
|
|
|
|
|
handles => { |
|
20
|
|
|
|
|
|
|
pop_object => ['pop'], |
|
21
|
|
|
|
|
|
|
add_object => ['push'], |
|
22
|
|
|
|
|
|
|
objects_count => ['count'], |
|
23
|
|
|
|
|
|
|
current_object => [ 'get', -1 ], |
|
24
|
|
|
|
|
|
|
root_object => [ 'get', 0 ], |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
6
|
|
|
6
|
|
291
|
sub _build_objects { [] } |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub parent_object { |
|
32
|
8
|
|
|
8
|
|
15
|
my ($self) = @_; |
|
33
|
8
|
100
|
|
|
|
382
|
if ( $self->objects_count >= 2 ) { |
|
34
|
4
|
|
|
|
|
152
|
return $self->objects->[-2]; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
4
|
50
|
|
|
|
181
|
return undef if $self->objects_count == 1; |
|
37
|
0
|
|
|
|
|
0
|
return $self->objects->[-1]; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
6
|
|
|
6
|
|
283
|
sub at_root_object { $_[0]->current_object == $_[0]->root_object } |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub load_class { |
|
43
|
10
|
|
|
10
|
|
16
|
my ( $self, $name ) = @_; |
|
44
|
10
|
|
|
|
|
48
|
Class::MOP::load_class($name); |
|
45
|
10
|
|
|
|
|
3650
|
return $name; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub create_and_add_object { |
|
49
|
10
|
|
|
10
|
|
21
|
my ( $self, $class, $el ) = @_; |
|
50
|
8
|
|
|
|
|
40
|
my %params = |
|
51
|
10
|
|
|
|
|
18
|
map { $_->{LocalName} => $_->{Value} } values %{ $el->{Attributes} }; |
|
|
10
|
|
|
|
|
33
|
|
|
52
|
10
|
|
|
|
|
103
|
my $obj = $class->new(%params); |
|
53
|
10
|
|
|
|
|
5619
|
$self->add_object($obj); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub start_element { |
|
58
|
10
|
|
|
10
|
|
6905
|
my ( $self, $el ) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
10
|
|
|
|
|
59
|
my $classname = $self->get_class_name($el); |
|
61
|
10
|
|
|
|
|
34
|
$el->{classname} = $classname; |
|
62
|
|
|
|
|
|
|
|
|
63
|
10
|
50
|
|
|
|
41
|
if ( my $class = $self->load_class($classname) ) { |
|
64
|
10
|
|
|
|
|
36
|
$self->create_and_add_object( $class => $el ); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
10
|
|
|
|
|
457
|
$self->add_element($el); |
|
67
|
10
|
|
|
|
|
41
|
return; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub append_to_parent { |
|
71
|
4
|
|
|
4
|
|
50
|
my ( $self, $parent, $el ) = @_; |
|
72
|
4
|
50
|
|
|
|
37
|
if ( my $method = $parent->can("add_$el->{LocalName}") ) { |
|
73
|
4
|
|
|
|
|
187
|
$parent->$method( $self->current_object ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub set_object_text { |
|
78
|
8
|
|
|
8
|
|
14
|
my ($self) = @_; |
|
79
|
8
|
50
|
|
|
|
367
|
$self->current_object->text( $self->text ) |
|
80
|
|
|
|
|
|
|
if $self->current_object->can('text'); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub end_element { |
|
84
|
8
|
|
|
8
|
|
1119
|
my ( $self, $el ) = @_; |
|
85
|
8
|
50
|
|
|
|
349
|
$self->set_object_text if $self->has_text; |
|
86
|
8
|
100
|
|
|
|
178
|
if ( my $parent = $self->parent_object ) { |
|
87
|
4
|
|
|
|
|
14
|
$self->append_to_parent( $parent => $el ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
6
|
100
|
|
|
|
2613
|
$self->pop_object unless $self->at_root_object; |
|
90
|
6
|
|
|
|
|
259
|
$self->pop_element; |
|
91
|
6
|
|
|
|
|
225
|
$self->reset_text; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub render { |
|
95
|
0
|
|
|
0
|
|
|
warn shift->root_object->dump; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
__END__ |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
XML::Toolkit::Loader::Filter - A class to ... |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 VERSION |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
version 0.15 |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use XML::Toolkit::Loader::Filter; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The XML::Toolkit::Loader::Filter class implements ... |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SUBROUTINES / METHODS |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 parent_object (method) |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Parameters: |
|
123
|
|
|
|
|
|
|
none |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Insert description of method here... |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 current_object (method) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Parameters: |
|
130
|
|
|
|
|
|
|
none |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Insert description of method here... |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 root_object (method) |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Parameters: |
|
137
|
|
|
|
|
|
|
none |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Insert description of method here... |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 load_class (method) |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Parameters: |
|
144
|
|
|
|
|
|
|
name |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Insert description of method here... |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 get_class_name (method) |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Parameters: |
|
151
|
|
|
|
|
|
|
name |
|
152
|
|
|
|
|
|
|
self |
|
153
|
|
|
|
|
|
|
el |
|
154
|
|
|
|
|
|
|
self |
|
155
|
|
|
|
|
|
|
el |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Insert description of method here... |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 render |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Parameters: |
|
162
|
|
|
|
|
|
|
none |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Insert description of subroutine here... |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Moose |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 NOTES |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
... |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
None known currently, please email the author if you find any. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Chris Prather (perigrin@domain.tld) |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 LICENCE |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Copyright 2009 by Chris Prather. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This software is free. It is licensed under the same terms as Perl itself. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |