line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Filter::Moose; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$XML::Filter::Moose::VERSION = '0.15'; |
4
|
|
|
|
|
|
|
} |
5
|
2
|
|
|
2
|
|
1591
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
17
|
|
6
|
2
|
|
|
2
|
|
14452
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2174
|
use MooseX::NonMoose; |
|
2
|
|
|
|
|
1975
|
|
|
2
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends qw(XML::SAX::Base); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has stack => ( |
13
|
|
|
|
|
|
|
isa => 'ArrayRef', |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
lazy_build => 1, |
16
|
|
|
|
|
|
|
clearer => 'reset_stack', |
17
|
|
|
|
|
|
|
traits => ['Array'], |
18
|
|
|
|
|
|
|
handles => { |
19
|
|
|
|
|
|
|
'add_element' => ['push'], |
20
|
|
|
|
|
|
|
'pop_element' => ['pop'], |
21
|
|
|
|
|
|
|
'root' => [ 'get', 0 ], |
22
|
|
|
|
|
|
|
'current_element' => [ 'get', -1 ], |
23
|
|
|
|
|
|
|
'stack_length' => ['count'], |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
9
|
|
376
|
sub _build_stack { [] } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has text => ( |
30
|
|
|
|
|
|
|
isa => 'Str', |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
traits => ['String'], |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
clearer => 'reset_text', |
35
|
|
|
|
|
|
|
predicate => 'has_text', |
36
|
|
|
|
|
|
|
default => sub { '' }, |
37
|
|
|
|
|
|
|
handles => { append_text => 'append', }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has cdata => ( isa => 'Bool', is => 'rw', ); |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
5
|
1
|
255
|
sub is_root { return shift->stack_length == 0 } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub parent_element { |
45
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
46
|
2
|
50
|
|
|
|
96
|
if ( $self->stack_length > 1 ) { |
47
|
0
|
|
|
|
|
0
|
return $self->stack->[-1]; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
85
|
$self->root; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub start_document { |
53
|
9
|
|
|
9
|
1
|
2767
|
my ( $self, $doc ) = @_; |
54
|
9
|
|
|
|
|
50
|
inner(); |
55
|
9
|
|
|
|
|
524
|
$self->reset_stack; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub start_element { |
59
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $el ) = @_; |
60
|
0
|
|
|
|
|
0
|
inner(); |
61
|
0
|
|
|
|
|
0
|
$self->add_element($el); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub characters { |
65
|
19
|
|
|
19
|
1
|
1385
|
my ( $self, $el ) = @_; |
66
|
19
|
|
|
|
|
94
|
inner(); |
67
|
19
|
100
|
|
|
|
893
|
$self->append_text( $el->{Data} ) if $el->{Data} =~ /\S/; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub end_element { |
71
|
0
|
|
|
0
|
1
|
|
my ( $self, $el ) = @_; |
72
|
0
|
|
|
|
|
|
inner(); |
73
|
0
|
|
|
|
|
|
$self->pop_element; |
74
|
0
|
|
|
|
|
|
$self->reset_text; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub end_document { |
78
|
0
|
|
|
0
|
1
|
|
my ( $self, $doc ) = @_; |
79
|
0
|
|
|
|
|
|
inner(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
XML::Filter::Moose - A Moose-ified base class for XML::SAX |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.15 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
package MyFilter; |
97
|
|
|
|
|
|
|
use Moose |
98
|
|
|
|
|
|
|
extends qw(XML::SAX::Base); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
augment start_element => start { |
101
|
|
|
|
|
|
|
my ($self, $el) = @_; |
102
|
|
|
|
|
|
|
$el->{Data} = [do something]; |
103
|
|
|
|
|
|
|
}; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The XML::Filter::Moose class implements ... |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 stack - ArrayRef |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 text - Str |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 root() |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns the root element, or the first element in the stack |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 current_element() |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Insert description of subroutine here... |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 is_root() |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Return true if we are currently working on the root element. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 parent_element() |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns the parent of the current element. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 start_document($document) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Fires at the start of the document. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 start_element($element) |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Fires at the start of an element. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 characters($element) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Fires at the start of a text node. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 end_element($element) |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Fires at the end of an element. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 end_document($document) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Fires at the end of a document. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<Moose|Moose> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<XML::SAX::Base|XML::SAX::Base> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
162
|
|
|
|
|
|
|
C<bug-xml-toolkit@rt.cpan.org>, or through the web interface at |
163
|
|
|
|
|
|
|
L<http://rt.cpan.org>. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Chris Prather (chris@prather.org) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Based upon L<XML::SAX::Base|XML::SAX::Base> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Kip Hampton (khampton@totalcinema.com) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Robin Berjon (robin@knowscape.com) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Matt Sergeant (matt@sergeant.org) |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 LICENCE |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright 2009 by Chris Prather. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This software is free. It is licensed under the same terms as Perl itself. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |