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