author | William Roberts <williamr@symbian.org> |
Fri, 29 May 2009 14:13:23 +0100 | |
changeset 1 | 4a4ca5a019bb |
parent 0 | 02cd6b52f378 |
permissions | -rw-r--r-- |
0
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
1 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
2 |
# This PerlSAX handler prints out all the PerlSAX events/callbacks |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
3 |
# it receives. Very useful when debugging. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
4 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
5 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
6 |
package XML::Handler::PrintEvents; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
7 |
use strict; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
8 |
use XML::Filter::SAXT; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
9 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
10 |
my @EXTRA_HANDLERS = ( 'ignorable_whitespace' ); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
11 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
12 |
sub new |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
13 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
14 |
my ($class, %options) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
15 |
bless \%options, $class; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
16 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
17 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
18 |
sub print_event |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
19 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
20 |
my ($self, $event_name, $event) = @_; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
21 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
22 |
printf "%-22s ", $event_name; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
23 |
if (defined $event) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
24 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
25 |
print join (", ", map { "$_ => [" . |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
26 |
(defined $event->{$_} ? $event->{$_} : "(undef)") |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
27 |
. "]" } keys %$event); |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
28 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
29 |
print "\n"; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
30 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
31 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
32 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
33 |
# This generates the PerlSAX handler methods for PrintEvents. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
34 |
# They basically forward the event to print_event() while adding the callback |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
35 |
# (event) name. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
36 |
# |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
37 |
for my $cb (@EXTRA_HANDLERS, map { @{$_} } values %XML::Filter::SAXT::SAX_HANDLERS) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
38 |
{ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
39 |
eval "sub $cb { shift->print_event ('$cb', \@_) }"; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
40 |
} |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
41 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
42 |
1; # package return code |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
43 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
44 |
__END__ |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
45 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
46 |
=head1 NAME |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
47 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
48 |
XML::Handler::PrintEvents - Prints PerlSAX events (for debugging) |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
49 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
50 |
=head1 SYNOPSIS |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
51 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
52 |
use XML::Handler::PrintEvents; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
53 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
54 |
my $pr = new XML::Handler::PrintEvents; |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
55 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
56 |
=head1 DESCRIPTION |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
57 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
58 |
This PerlSAX handler prints the PerlSAX events it receives to STDOUT. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
59 |
It can be useful when debugging PerlSAX filters. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
60 |
It supports all PerlSAX handler including ignorable_whitespace. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
61 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
62 |
=head1 AUTHOR |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
63 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
64 |
Send bug reports, hints, tips, suggestions to Enno Derksen at |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
65 |
<F<enno@att.com>>. |
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
66 |
|
02cd6b52f378
adding synch hg to p4 & create dummy foundation structure scripts
tahirm@symbian.org
parents:
diff
changeset
|
67 |
=cut |