blob: 6d62aff526b5f98f63ab96064409e1053b1bc882 (
plain)
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
|
BEGIN {print "1..5\n";}
END {print "not ok 1\n" unless $loaded;}
use XML::Parser;
$loaded = 1;
print "ok 1\n";
################################################################
# Check default external entity handler
my $txt = '';
sub txt {
my ($xp, $data) = @_;
$txt .= $data;
}
my $docstring =<<'End_of_XML;';
<!DOCTYPE foo [
<!ENTITY a SYSTEM "a.ent">
<!ENTITY b SYSTEM "b.ent">
<!ENTITY c SYSTEM "c.ent">
]>
<foo>
a = "&a;"
b = "&b;"
And here they are again in reverse order:
b = "&b;"
a = "&a;"
</foo>
End_of_XML;
open(ENT, '>a.ent') or die "Couldn't open a.ent for writing";
print ENT "This ('&c;') is a quote of c";
close(ENT);
open(ENT, '>b.ent') or die "Couldn't open b.ent for writing";
print ENT "Hello, I'm B";
close(ENT);
open(ENT, '>c.ent') or die "Couldn't open c.ent for writing";
print ENT "Hurrah for C";
close(ENT);
my $p = new XML::Parser(Handlers => {Char => \&txt});
$p->parse($docstring);
my %check = (a => "This ('Hurrah for C') is a quote of c",
b => "Hello, I'm B");
my $tstcnt = 2;
while ($txt =~ /([ab]) = "(.*)"/g) {
my ($k, $v) = ($1, $2);
unless ($check{$k} eq $v) {
print "not ";
}
print "ok $tstcnt\n";
$tstcnt++;
}
unlink('a.ent');
unlink('b.ent');
unlink('c.ent');
|