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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.