Gossamer Forum
Home : General : Perl Programming :

Perl - XML::Validator::Schema

Quote Reply
Perl - XML::Validator::Schema
I've made a function that parses a string using a XSD-schema
This takes a lot of time because the validator needs to open the XSD-file every time I call the function.

Is there no other way to use a XSD-schema or are there no other arguments for the validator

my code:

sub Parser {
my ($in) = @_;

$validator = XML::Validator::Schema->new (file => 'file.xsd');
$parser = XML::SAX::ParserFactory->parser (Handler => $validator);

eval {
$parser->parse_string ($in)
return $@, $in;

Quote Reply
Re: [muzicman] Perl - XML::Validator::Schema In reply to
I've found the solution
if jou use cache => 1 perl doesn't read the file everytime

Smile Smile

my $validator = XML::Validator::Schema->new (file => 'aanbrengerAangepast.xml', cache => 1);