655
|
1 |
# This template file is in the Public Domain.
|
|
2 |
# You may do anything you want with this file.
|
|
3 |
#
|
|
4 |
# $Id: Sample.pm,v 1.4 1999/08/16 16:04:03 kmacleod Exp $
|
|
5 |
#
|
|
6 |
|
|
7 |
package XML::Handler::Sample;
|
|
8 |
|
|
9 |
use vars qw{ $AUTOLOAD };
|
|
10 |
|
|
11 |
sub new {
|
|
12 |
my $type = shift;
|
|
13 |
my $self = ( $#_ == 0 ) ? shift : { @_ };
|
|
14 |
|
|
15 |
return bless $self, $type;
|
|
16 |
}
|
|
17 |
|
|
18 |
# Basic PerlSAX
|
|
19 |
sub start_document { print "start_document\n"; }
|
|
20 |
sub end_document { print "end_document\n"; }
|
|
21 |
sub start_element { print "start_element\n"; }
|
|
22 |
sub end_element { print "end_element\n"; }
|
|
23 |
sub characters { print "characters\n"; }
|
|
24 |
sub processing_instruction { print "processing_instruction\n"; }
|
|
25 |
sub ignorable_whitespace { print "ignorable_whitespace\n"; }
|
|
26 |
|
|
27 |
# Additional expat callbacks in XML::Parser::PerlSAX
|
|
28 |
sub comment { print "comment\n"; }
|
|
29 |
sub notation_decl { print "notation_decl\n"; }
|
|
30 |
sub unparsed_entity_decl { print "unparsed_entity_decl\n"; }
|
|
31 |
sub entity_decl { print "entity_decl\n"; }
|
|
32 |
sub element_decl { print "element_decl\n"; }
|
|
33 |
sub doctype_decl { print "doctype_decl\n"; }
|
|
34 |
sub xml_decl { print "xml_decl\n"; }
|
|
35 |
|
|
36 |
# Additional SP/nsgmls callbacks in XML::ESISParser
|
|
37 |
sub start_subdoc { print "start_subdoc\n"; }
|
|
38 |
sub end_subdoc { print "start_subdoc\n"; }
|
|
39 |
sub appinfo { print "appinfo\n"; }
|
|
40 |
sub internal_entity_ref { print "sdata\n"; }
|
|
41 |
sub external_entity_ref { print "sdata\n"; }
|
|
42 |
sub record_end { print "record_end\n"; }
|
|
43 |
sub internal_entity_decl { print "internal_entity_decl\n"; }
|
|
44 |
sub external_entity_decl { print "external_entity_decl\n"; }
|
|
45 |
sub external_sgml_entity_decl { print "external_sgml_entity_decl\n"; }
|
|
46 |
sub subdoc_entity_decl { print "subdoc_entity_decl\n"; }
|
|
47 |
sub notation { print "notation\n"; }
|
|
48 |
sub error { print "error\n"; }
|
|
49 |
sub conforming { print "conforming\n"; }
|
|
50 |
|
|
51 |
# Others
|
|
52 |
sub AUTOLOAD {
|
|
53 |
my $self = shift;
|
|
54 |
|
|
55 |
my $method = $AUTOLOAD;
|
|
56 |
$method =~ s/.*:://;
|
|
57 |
return if $method eq 'DESTROY';
|
|
58 |
|
|
59 |
print "UNRECOGNIZED $method\n";
|
|
60 |
}
|
|
61 |
|
|
62 |
1;
|
|
63 |
|
|
64 |
__END__
|
|
65 |
|
|
66 |
=head1 NAME
|
|
67 |
|
|
68 |
XML::Handler::Sample - a trivial PerlSAX handler
|
|
69 |
|
|
70 |
=head1 SYNOPSIS
|
|
71 |
|
|
72 |
use XML::Parser::PerlSAX;
|
|
73 |
use XML::Handler::Sample;
|
|
74 |
|
|
75 |
$my_handler = XML::Handler::Sample->new;
|
|
76 |
|
|
77 |
XML::Parser::PerlSAX->new->parse(Source => { SystemId => 'REC-xml-19980210.xml' },
|
|
78 |
Handler => $my_handler);
|
|
79 |
|
|
80 |
=head1 DESCRIPTION
|
|
81 |
|
|
82 |
C<XML::Handler::Sample> is a trivial PerlSAX handler that prints out
|
|
83 |
the name of each event it receives. The source for
|
|
84 |
C<XML::Handler::Sample> lists all the currently known PerlSAX
|
|
85 |
handler methods.
|
|
86 |
|
|
87 |
C<XML::Handler::Sample> is intended for Perl module authors who wish
|
|
88 |
to look at example PerlSAX handler modules. C<XML::Handler::Sample>
|
|
89 |
can be used as a template for writing your own PerlSAX handler
|
|
90 |
modules. C<XML::Handler::Sample> is in the Public Domain and can be
|
|
91 |
used for any purpose without restriction.
|
|
92 |
|
|
93 |
=head1 AUTHOR
|
|
94 |
|
|
95 |
Ken MacLeod, ken@bitsko.slc.ut.us
|
|
96 |
|
|
97 |
=head1 SEE ALSO
|
|
98 |
|
|
99 |
perl(1), PerlSAX.pod(3)
|
|
100 |
|
|
101 |
=cut
|