Hi, All:

First mesg on this list.  Here is my problem. I have to user XML::Xerces
(2.3.0) to validate xml file against xsd. It works fine and generates
informative errors when validation failed. The problem is that I need to
remove the files after validation no matter if the validation passes or
fails. But with the following code, when falidation errors generated, the
XML file can never be unlinked. When validation is good, the file can be
removed. I think the file handler is never been released by the parser.
What am I missing here? Thanks.

Tony Yan

####

my $parser = XML::Xerces::XercesDOMParser->new();

eval {

$parser->setValidationScheme (1);
$parser->setDoNamespaces (1);
$parser->setCreateEntityReferenceNodes(1);
$parser->setDoSchema(1);
$parser->setExternalNoNamespaceSchemaLocation("sample.xsd");
$parser->setValidationSchemaFullChecking(1);


};
print $@ if $@;

my $error_handler = XML::Xerces::PerlErrorHandler->new();
$parser->setErrorHandler($error_handler);

###################### start to parse and/or validate #####################
my $xml_src;
eval {
  $xml_src = XML::Xerces::LocalFileInputSource->new("sample.xml");
  if ($xml_src) {
      $parser->parse ($xml_src);
  }

};
print $@ if $@;

############### clean up the files ############################
eval{
      $parser->reset();
      unlink("sample.xml") or print "cannot remove sample.xml";
      unlink("sample.xsd") or print "cannot remove sample.xsd";
};

print $@ if $@;






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to