in reply to Improving script that uses xmllint to validate

That would depend on xmllint. The xmllint program parses one or more XML files, specified on the command line as xmlfile.
  • Comment on Re: Improving script that uses xmllint to validate

Replies are listed 'Best First'.
Re^2: Improving script that uses xmllint to validate
by matrixmadhan (Beadle) on Dec 26, 2008 at 09:13 UTC
    Thanks for the reply.

    Currently am parsing only one xml file with xmllint

    Passing multiple files to xmllint involves the overhead of creating multiple files, cleaning them after it is being used etc.
      Hmm, try
      #!/usr/bin/perl -- use strict; use warnings; use XML::LibXML; my $schemafile = 'base-schema.xsd'; my $schema = XML::LibXML::RelaxNG->new( location => $schemafile); my $filename = 'foo.xml'; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); $schema->validate($doc); print "\n\nWe've made it this far without dying (ie you read this mess +age) $schemafile is valid, and so is $filename \n\n"
        Thanks for the reply. Much appreciated.

        I will try it out.

        With this approach, schema file (xsd) need not be parsed, validated, loaded each and every time.