Perl 使用XML::Schematron::LibXSLT验证XML文件
我想使用XML::Schematron::LibXSLT验证XML文件 下面是我尝试过的代码,它使用.sch schemafile和XML文件作为参数Perl 使用XML::Schematron::LibXSLT验证XML文件,perl,xslt,xml-validation,schematron,Perl,Xslt,Xml Validation,Schematron,我想使用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
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";
它在Schematron.pl第14行给出错误无法通过包“XML::Schematron::LibXSLT”找到对象方法“new”。
这告诉模块没有新方法。可能是模块已更新。所以我也试过了
use XML::Schematron;
my $pseudotron = XML::Schematron->new_with_traits( traits => ['LibXSLT'], schema => "$schema_file");
my $messages = $pseudotron->verify($xml_file);
print "$messages\n";
但它什么也不印。不知道怎么了
同样在《大纲》中,第二次和第三次使用给出了相同的错误
同样的帖子也请参考链接文档显示
使用XML::Schematron
,而不是使用XML::Schematron::LibXSLT
@chobara我也尝试过<代码>使用XML::Schematron::LibXSLT在许多在线教程中使用,我在第一次尝试时尝试了这些教程,在这里我遇到了上述错误。请检查我的第二次尝试。