home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / perl5 / XML / Perl2SAX.pm < prev    next >
Encoding:
Text File  |  2003-10-21  |  2.5 KB  |  121 lines

  1. #
  2. # Copyright (C) 1998 Ken MacLeod
  3. # XML::Perl2SAX is free software; you can redistribute it and/or
  4. # modify it under the same terms as Perl itself.
  5. #
  6. # $Id: Perl2SAX.pm,v 1.3 1999/12/22 21:15:00 kmacleod Exp $
  7. #
  8.  
  9. use strict;
  10.  
  11. package XML::Perl2SAX;
  12.  
  13. use vars qw{ $VERSION };
  14.  
  15. # will be substituted by make-rel script
  16. $VERSION = "0.08";
  17.  
  18. sub new {
  19.     my $type = shift;
  20.     my $self = ($#_ == 0) ? shift : { @_ };
  21.  
  22.     return bless $self, $type;
  23. }
  24.  
  25. sub start_document {
  26.     my $self = shift;
  27.     my $properties = ($#_ == 0) ? shift : { @_ };
  28.  
  29.     if ($properties->{Locator}) {
  30.     $self->{DocumentHandler}->setDocumentLocator($properties->{Locator});
  31.     }
  32.  
  33.     $self->{DocumentHandler}->startDocument;
  34. }
  35.  
  36. sub end_document {
  37.     my $self = shift;
  38.  
  39.     $self->{DocumentHandler}->endDocument;
  40. }
  41.  
  42. sub start_element {
  43.     my $self = shift;
  44.     my $properties = shift;
  45.  
  46.     # FIXME depends on how Perl SAX treats attributes
  47.     $self->{DocumentHandler}->startElement($properties->{Name},
  48.                        $properties->{Attributes});
  49. }
  50.  
  51. sub end_element {
  52.     my $self = shift;
  53.     my $properties = shift;
  54.  
  55.     $self->{DocumentHandler}->endElement($properties->{Name});
  56. }
  57.  
  58. sub characters {
  59.     my $self = shift;
  60.     my $properties = shift;
  61.  
  62.     $self->{DocumentHandler}->characters($properties->{Data},
  63.                      0,
  64.                      length($properties->{Data}));
  65. }
  66.  
  67. sub ignorable_whitespace {
  68.     my $self = shift;
  69.     my $properties = shift;
  70.  
  71.     $self->{DocumentHandler}->ignorableWhitespace($properties->{Data},
  72.                           0,
  73.                           length($properties->{Data}));
  74. }
  75.  
  76. sub processing_instruction {
  77.     my $self = shift;
  78.     my $properties = shift;
  79.  
  80.     $self->{DocumentHandler}->processingInstruction($properties->{Target},
  81.                             $properties->{Data});
  82. }
  83.  
  84. 1;
  85.  
  86. __END__
  87.  
  88. =head1 NAME
  89.  
  90. XML::SAX2Perl -- translate Perl SAX methods to Java/CORBA style methods
  91.  
  92. =head1 SYNOPSIS
  93.  
  94.  use XML::Perl2SAX;
  95.  
  96.  $perl2sax = XML::Perl2SAX(handler => $java_style_handler);
  97.  
  98. =head1 DESCRIPTION
  99.  
  100. C<XML::Perl2SAX> is a SAX filter that translates Perl style SAX
  101. methods to Java/CORBA style method calls.  This module performs the
  102. inverse operation from C<XML::SAX2Perl>.
  103.  
  104. C<Perl2SAX> is a Perl SAX document handler.  The `C<new>' method takes
  105. a `C<handler>' argument that is a Java/CORBA style handler that the
  106. new Perl2SAX instance will call.  The SAX interfaces are defined at
  107. <http://www.megginson.com/SAX/>.
  108.  
  109. =head1 AUTHOR
  110.  
  111. Ken MacLeod <ken@bitsko.slc.ut.us>
  112.  
  113. =head1 SEE ALSO
  114.  
  115. perl(1), XML::Perl2SAX(3).
  116.  
  117.  Extensible Markup Language (XML) <http://www.w3c.org/XML/>
  118.  Simple API for XML (SAX) <http://www.megginson.com/SAX/>
  119.  
  120. =cut
  121.