1 |
package XML::Parser::StreamWriter; |
2 |
|
3 |
use Data::Dumper; |
4 |
|
5 |
use strict; |
6 |
use warnings; |
7 |
use vars qw($VERSION $Noempty $Latin); |
8 |
|
9 |
$VERSION = '0.01'; |
10 |
|
11 |
$XML::Parser::Built_In_Styles{StreamWriter} = 1; |
12 |
|
13 |
|
14 |
=pod |
15 |
|
16 |
Modes: |
17 |
o write to file |
18 |
o return as string |
19 |
o return as DOM |
20 |
|
21 |
=cut |
22 |
|
23 |
|
24 |
sub StartDocument { |
25 |
my $expat = shift; |
26 |
#$expat->{Output} = |
27 |
#print STDERR "StartDocument", "\n"; |
28 |
} |
29 |
|
30 |
sub StartTag { |
31 |
my $expat = shift; |
32 |
my $tag = shift; |
33 |
my $attribs = shift; |
34 |
|
35 |
#print STDERR Dumper($attribs); |
36 |
#print STDERR Dumper(\%_); |
37 |
|
38 |
#print STDERR "StartTag: $tag", "\n"; |
39 |
$expat->{Writer}->startTag($tag, %_); |
40 |
return; |
41 |
|
42 |
if (%_) { |
43 |
$expat->{Writer}->startTag($_, %_); |
44 |
} else { |
45 |
$expat->{Writer}->startTag($_); |
46 |
} |
47 |
} |
48 |
|
49 |
sub EndTag { |
50 |
my $expat = shift; |
51 |
my $tag = shift; |
52 |
#print STDERR "EndTag: $tag", "\n"; |
53 |
$expat->{Writer}->endTag($tag); |
54 |
} |
55 |
|
56 |
sub Text { |
57 |
my $expat = shift; |
58 |
my $data = shift; |
59 |
#print STDERR "Text: ", "\n"; |
60 |
#print STDERR |
61 |
$expat->{Writer}->characters($data); |
62 |
} |
63 |
|
64 |
sub PI { |
65 |
#print STDERR "PI", "\n"; |
66 |
} |
67 |
|
68 |
sub EndDocument { |
69 |
my $expat = shift; |
70 |
#print STDERR "END!!!", "\n"; |
71 |
$expat->{Writer}->end(); |
72 |
} |
73 |
|
74 |
|
75 |
1; |
76 |
__END__ |