From 30ef73ab662a90c39f17cf0b08db9dc33ee2679a Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Mon, 30 May 2016 10:22:59 +0200 Subject: [PATCH] Cmake xhtml export tests: Missing script for commit 416242476289d423eb392345555f3dad941df544 --- development/autotests/examineXmllintOutput.pl | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 development/autotests/examineXmllintOutput.pl diff --git a/development/autotests/examineXmllintOutput.pl b/development/autotests/examineXmllintOutput.pl new file mode 100755 index 0000000000..36007e2462 --- /dev/null +++ b/development/autotests/examineXmllintOutput.pl @@ -0,0 +1,77 @@ +#! /usr/bin/env perl +# -*- mode: perl; -*- + +# Examine output of 'xmllint --sax --html' + +my $file = $ARGV[0]; # file to examine + +my @tag = (); # tag entries = {"name" => strng, "count" => sequence number} +my $tagindex = 0; # next tag to be written +$tag[$tagindex] = {}; +my %errors = (); + +if (open(FI, $file)) { + my $line = 0; + my $saxchartoprint = 0; + while(my $l = ) { + $line++; + chomp($l); + if ($l =~ /^SAX.startElementNs\(([^, \)]+)/) { + # new tag + my $tag = $1; + $saxchartoprint = 0; + #print "Start tag $tag at line $line, tagindex = $tagindex\n"; + my $newentry = 1; + if (defined($tag[$tagindex]->{"name"})) { + if ($tag[$tagindex]->{"name"} eq $tag) { + $tag[$tagindex]->{"count"} = $tag[$tagindex]->{"count"}+1; + $newentry = 0; + } + } + if ($newentry) { + $tag[$tagindex] = {}; + $tag[$tagindex]->{"name"} = $tag; + $tag[$tagindex]->{"count"} = 1; + } + $tagindex++; + $tag[$tagindex] = {}; + } + elsif ($l =~ /^SAX.endElementNs\(([^, \)]+)/) { + $saxchartoprint = 0; + my $tag = $1; + $tagindex--; + #print "End tag $tag at line $line, tagindex = $tagindex\n"; + if ($tagindex < 0) { + die("tagindex < 0"); + } + if ($tag[$tagindex]->{"name"} ne $tag) { + die("End tag $tag does not match " . $tag[$tagindex]->{"name"} . " at line $line"); + } + } + elsif ($l =~ /^SAX.error: (.*)$/) { + my $err = $1; + if ($err =~ /Entity\s+'([a-zA-Z0-9]+)'\s+not defined$/) { + # Ignore Entity 'xxxx' not defined + } + elsif (! defined($errors{$err})) { + my $errmsg = ""; + my $trenner = ""; + for (my $i = 0; $i < $tagindex; $i++) { + $errmsg .= $trenner . $tag[$i]->{"name"} . "(" . $tag[$i]->{"count"} . ")"; + $trenner = ", "; + } + $errors{$err} = $errmsg; + print "$err -> $errmsg\n"; + # Print the next 3 lines starting with 'SAX.characters(' + $saxchartoprint = 3; + } + } + elsif ($saxchartoprint > 0) { + $saxchartoprint--; + if ($l =~ /^SAX.characters\(([^\)]+)\)/) { + print "\t$1\n"; + } + } + } +} +exit(0); -- 2.39.2