4 # Examine output of 'xmllint --sax --html'
6 my $file = $ARGV[0]; # file to examine
8 my @tag = (); # tag entries = {"name" => strng, "count" => sequence number}
9 my $tagindex = 0; # next tag to be written
13 if (open(FI, $file)) {
16 my $saxchartoprint = 0;
20 if ($l =~ /^SAX.startElementNs\(([^, \)]+)/) {
24 #print "Start tag $tag at line $line, tagindex = $tagindex\n";
26 if (defined($tag[$tagindex]->{"name"})) {
27 if ($tag[$tagindex]->{"name"} eq $tag) {
28 $tag[$tagindex]->{"count"} = $tag[$tagindex]->{"count"}+1;
34 $tag[$tagindex]->{"name"} = $tag;
35 $tag[$tagindex]->{"count"} = 1;
40 elsif ($l =~ /^SAX.endElementNs\(([^, \)]+)/) {
44 #print "End tag $tag at line $line, tagindex = $tagindex\n";
48 if ($tag[$tagindex]->{"name"} ne $tag) {
49 die("End tag $tag does not match " . $tag[$tagindex]->{"name"} . " at line $line");
52 elsif ($l =~ /^SAX.error: (.*)$/) {
54 if ($err =~ /Entity\s+'([a-zA-Z0-9]+)'\s+not defined$/) {
55 # Ignore Entity 'xxxx' not defined
57 elsif (! defined($errors{$err})) {
60 for (my $i = 0; $i < $tagindex; $i++) {
61 $errmsg .= $trenner . $tag[$i]->{"name"} . "(" . $tag[$i]->{"count"} . ")";
64 $errors{$err} = $errmsg;
65 print "$err -> $errmsg\n";
66 # Print the next 3 lines starting with 'SAX.characters('
70 elsif ($l =~ /: parser error :\s+(.*)$/) {
72 $errors{$err} = $errmsg;
73 if ($errmsg =~ /Entity\s+'([a-zA-Z0-9]+)'\s+not defined/) {
75 if (! defined($entities{$entity})) {
76 $entities{$entity} = 1;
82 die("Unknown error $l");
85 elsif ($saxchartoprint > 0) {
87 if ($l =~ /^SAX.characters\(([^\)]+)\)/) {