in reply to XML validating (no DTD)

Change

$xp->parsefile($xml_file); local $XML::Checker::FAIL = \&my_fail;

to

local $XML::Checker::FAIL = \&my_fail; $xp->parsefile($xml_file);

It does no good to set the error handler after the checking is done.