#!/usr/local/bin/perl use strict; use Getopt::Long; use XML::Checker; use XML::Checker::Parser; my %expat_options = (KeepCDATA => 1);#, Handlers => { Unparsed => \&my_Unparsed_handler }); my $parser = new XML::Checker::Parser (%expat_options); my %unique_h; unless (@ARGV) { usage(); exit; } local $XML::Checker::FAIL = \&fail_handler; foreach my $f (@ARGV) { $parser->parsefile ($f); } map{print STDERR "$_\n"}values %unique_h; print STDERR "DONE\n"; my $status = scalar(keys %unique_h); exit $status; # code < 200, invalid xml element/attr? # code >= 200, a warning or info message? sub fail_handler { my $code = shift; my $msg = shift; my @context = @_; my $k = "ERROR-CODE=$code: $msg"; if ($code < 200) { $unique_h{$k} = sprintf("$k\n\tContext: %s",join(", ",@context)); } } sub usage { print <