I'm using XML::Check::Parser to do a DTD validation on a set of files. While it's not a problem to validate a single file, I run into issues when I attempt to use the parsefile() method against multiple files:
my $checker = new XML::Checker::Parser(Handlers => {});
foreach ($files) {
print "Checking file $_ ...\n";
eval {
$checker->parsefile($_);
};
if ($@) {
(print $error)
}
}
What happens is that once the second file is loaded, the checker reports DTD errors that make it look like it still thinks I'm reading in a single file:
Checking file file1.xml ...
Checking file file2.xml ...
(115, ELEMENT [foo] already defined Element foo line 2 column 67 byte
+90)
Checking file file3.xml ...
(115, ELEMENT [foo] already defined Element foo line 2 column 67 byte
+90)
...
I can get around this by putting the
my $checker = new XML::Parser::Checker ... line inside the
foreach loop, but that seems terribly inelegant to me.
Is there a better way to do this? Is there a method in XML::Checker::Parser I'm not seeing to tell it to expect a new complete XML file?