blob: 6cde2a7d2d584353ff15542322b4b49660dca9ff (
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
|
BEGIN {print "1..4\n";}
END {print "not ok 1\n" unless $loaded;}
use XML::Parser;
$loaded = 1;
print "ok 1\n";
my $cmnt_count = 0;
my $pi_count = 0;
my $between_count = 0;
my $authseen = 0;
sub init {
my $xp = shift;
$xp->skip_until(1); # Skip through prolog
}
sub proc {
$pi_count++;
}
sub cmnt {
$cmnt_count++;
}
sub start {
my ($xp, $el) = @_;
my $ndx = $xp->element_index;
if (! $authseen and $el eq 'authlist') {
$authseen = 1;
$xp->skip_until(2000);
}
elsif ($authseen and $ndx < 2000) {
$between_count++;
}
}
my $p = new XML::Parser(Handlers => {Init => \&init,
Start => \&start,
Comment => \&cmnt,
Proc => \&proc
});
$p->parsefile('samples/REC-xml-19980210.xml');
print "not " if $between_count;
print "ok 2\n";
print "not " if $pi_count;
print "ok 3\n";
print "not " unless $cmnt_count == 5;
print "ok 4\n";
|