3

I want to verify XML file using XML::Schematron::LibXSLT here is code i tried which uses .sch schemafile and XML file as argument

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";

It is giving error Can't locate object method "new" via package "XML::Schematron::LibXSLT" at schematron.pl line 14. which tell module don't have new method. May be module is updated.

So I also tried

use XML::Schematron;

my $pseudotron = XML::Schematron->new_with_traits( traits => ['LibXSLT'], schema => "$schema_file");
my $messages = $pseudotron->verify($xml_file);

print "$messages\n";

But it dosen't print anything. Don't know what is wrong!

Also at https://metacpan.org/pod/XML::Schematron::LibXSLT Synopsis, 2nd and 3rd use are giving same error.

Please refer to the perlmonk link as well for the same post

waghso
  • 623
  • 7
  • 23
  • The documentation shows `use XML::Schematron`, not `use XML::Schematron::LibXSLT`. – choroba Jul 25 '14 at 09:46
  • @chobara I also tried it. `use XML::Schematron::LibXSLT` is used in many online tutorials which i tried in first attempt, where I got above error. Please check my second attempt. – waghso Jul 25 '14 at 09:49

0 Answers0