| 1 | # | ||||||||||
| 2 | # This PerlSAX handler prints out all the PerlSAX events/callbacks | ||||||||||
| 3 | # it receives. Very useful when debugging. | ||||||||||
| 4 | # | ||||||||||
| 5 | |||||||||||
| 6 | package XML::Handler::PrintEvents; | ||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use XML::Filter::SAXT; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | $VERSION = 0.01; | |||||||||
| 12 | |||||||||||
| 13 | 1 | my @EXTRA_HANDLERS = ( 'ignorable_whitespace' ); | |||||||||
| 14 | |||||||||||
| 15 | sub new | ||||||||||
| 16 | 0 | ▶ | { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 0 | my ($class, %options) = @_; | |||||||||
| 18 | 0 | bless \%options, $class; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | sub print_event | ||||||||||
| 22 | 0 | ▶ | { | ||||||||
|
Subroutine
print_event: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 23 | 0 | my ($self, $event_name, $event) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 0 | printf "%-22s ", $event_name; | |||||||||
| 26 | 0 | ▶ | if (defined $event) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | { | ||||||||||
| 28 | 0 | print join (", ", map { "$_ => [" . | |||||||||
| 29 | 0 | ▶ | (defined $event->{$_} ? $event->{$_} : "(undef)") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | . "]" } keys %$event); | ||||||||||
| 31 | } | ||||||||||
| 32 | 0 | print "\n"; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | # | ||||||||||
| 36 | # This generates the PerlSAX handler methods for PrintEvents. | ||||||||||
| 37 | # They basically forward the event to print_event() while adding the callback | ||||||||||
| 38 | # (event) name. | ||||||||||
| 39 | # | ||||||||||
| 40 | 1 | for my $cb (@EXTRA_HANDLERS, map { @{$_} } values %XML::Filter::SAXT::SAX_HANDLERS) | |||||||||
| 41 | { | ||||||||||
| 42 | 0 | ▶ | eval "sub $cb { shift->print_event ('$cb', \@_) }"; | ||||||||
|
Subroutine
attlist_decl: not called CC=1 SCAR=6.2
Subroutine
characters: not called CC=1 SCAR=6.2
Subroutine
comment: not called CC=1 SCAR=6.2
Subroutine
doctype_decl: not called CC=1 SCAR=6.2
Subroutine
element_decl: not called CC=1 SCAR=6.2
Subroutine
end_cdata: not called CC=1 SCAR=6.2
Subroutine
end_document: not called CC=1 SCAR=6.2
Subroutine
end_element: not called CC=1 SCAR=6.2
Subroutine
entity_decl: not called CC=1 SCAR=6.2
Subroutine
entity_reference: not called CC=1 SCAR=6.2
Subroutine
ignorable_whitespace: not called CC=1 SCAR=6.2
Subroutine
notation_decl: not called CC=1 SCAR=6.2
Subroutine
processing_instruction: not called CC=1 SCAR=6.2
Subroutine
resolve_entity: not called CC=1 SCAR=6.2
Subroutine
set_document_locator: not called CC=1 SCAR=6.2
Subroutine
start_cdata: not called CC=1 SCAR=6.2
Subroutine
start_document: not called CC=1 SCAR=6.2
Subroutine
start_element: not called CC=1 SCAR=6.2
Subroutine
unparsed_entity_decl: not called CC=1 SCAR=6.2
Subroutine
xml_decl: not called CC=1 SCAR=6.2
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
| |||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; # package return code | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||