XML::Schematron::LibXSLT を使用して XML ファイルを検証したい ここでは、.sch schemafile と XML ファイルを引数として使用するコードを試しました。
use XML::Schematron::LibXSLT;
my $schema_file = $ARGV[0];
my $xml_file = $ARGV[1];
die "Usage: perl schematron.pl schemafile XMLfile.\n"
unless defined $schema_file and defined $xml_file;
my $tron = XML::Schematron::LibXSLT->new();
$tron->schema($schema_file);
my $ret = $tron->verify($xml_file);
print $ret . "\n";
Can't locate object method "new" via package "XML::Schematron::LibXSLT" at schematron.pl line 14.
モジュールに新しいメソッドがないことを伝えるエラーが発生しています。モジュールが更新されている可能性があります。
だから私も試しました
use XML::Schematron;
my $pseudotron = XML::Schematron->new_with_traits( traits => ['LibXSLT'], schema => "$schema_file");
my $messages = $pseudotron->verify($xml_file);
print "$messages\n";
しかし、それは何も印刷しません。何が悪いのかわからない!
またhttps://metacpan.org/pod/XML::Schematron::LibXSLT Synopsisで、2 回目と 3 回目の使用で同じエラーが発生しています。
同じ投稿については、 perlmonkのリンクも参照してください。