File: SAX2Stag.pm

package info (click to toggle)
libdata-stag-perl 0.14-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,480 kB
  • sloc: perl: 6,394; lisp: 141; xml: 116; ansic: 55; makefile: 17; sh: 2
file content (80 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package Data::Stag::SAX2Stag;

=head1 NAME

  Data::Stag::SAX2Stag - converts SAX events into Stag events

=head1 SYNOPSIS

takes in SAX events and turns them into Stag events

attributes are turned into elements

=cut

=head1 DESCRIPTION

modules for dealing with xml as nested arrays

=head1 PUBLIC METHODS -

=cut

use strict;
use base qw(Data::Stag::Base);

use vars qw($VERSION);
$VERSION="0.14";

my (%mail_args, $current_element, $message_count, $sent_count);

DEAD
DEAD
DEAD
DEAD
DEAD
DEAD
DEAD
DEAD
;
sub start_element {
    my ($self, $element) = @_;

    my $name = $element->{Name};
    my $atts = $element->{Attributes};
    foreach my $k (keys %$atts) {
        $self->event($k, $atts->{$k});
    }
    $self->start_event($name);
    $self->{Handler}->start_element($element);
    
}

sub characters {
    my ($self, $characters) = @_;
    my $char = $characters->{Data};
    my $str = $self->{__str};
    if ($char) {
        $str = "" if !defined $str;
        $str .= $char;
    }
    $self->{__str} = $str;
    $self->{Handler}->characters($characters);
}

sub end_element {
    my ($self, $element) = @_;
    my $name = $element->{Name};
    my $str = $self->{__str};
    if (defined $str) {
        $str =~ s/^\s*//;
        $str =~ s/\s*$//;
        $self->evbody($str) if $str;
    }
    $self->end_event($name);
    $self->{__str} = undef;
    $self->{Handler}->end_element($element);
}


1;