使用XML :: Schematron :: LibXSLT验证XML文件

时间:2014-07-25 09:39:11

标签: 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 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 提要,第二次和第三次使用都会出现同样的错误。

请参阅同一帖子的perlmonk链接

0 个答案:

没有答案
相关问题