Jason:

As soon as I read the scope approach, I felt that should work. It did!.
Thanks! I am using win2k. I am moving this to unix now.

BTW, besides the scope, is there another way to release the object my
$parser? I used reset() etc. Didn't work.

Regards,

- Tony





                                                                                       
                                                
                      [EMAIL PROTECTED]                                                
                                                
                      tics.com (Jason          To:       [EMAIL PROTECTED]             
                                      
                      E. Stewart)              cc:                                     
                                                
                      Sent by: "Jason          Subject:  Re: cannot remove file after 
XercesDOMParser validation                       
                      E. Stewart"                                                      
                                                
                      <[EMAIL PROTECTED]                                               
                                                 
                      atics.com>                                                       
                                                
                                                                                       
                                                
                                                                                       
                                                
                      12/19/2003 01:58                                                 
                                                
                      AM                                                               
                                                
                      Please respond to                                                
                                                
                      xerces-p-dev                                                     
                                                
                                                                                       
                                                
                                                                                       
                                                




"Bin Yan" <[EMAIL PROTECTED]> writes:

> First mesg on this list.

Welcome! I hope we can help you out.

> 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.

Which platform are you using? I'm curious because this doesn't sound
like a Unix/Linux type issue.

> 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?

Sounds very odd to me, but here would be what I would try:

1) scoping: place the parser in a different scope so that once parsing
   is complete, the interpreter is free to clean up the parser and all
   the memory/objects it contains.

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

    # do parsing stuff
  }

  unlink('foo.xml');
  unlink('foo.xsd');

2) try putting the unlink code in an END block. This will allow perl
   to also clean up any resources that may be open and blocking the
   file removal.

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

  # do parsing stuff

  END {
    unlink('foo.xml');
    unlink('foo.xsd');
  }



> ####

[snip]

> eval{
>       unlink("sample.xml") or print "cannot remove sample.xml";
>       unlink("sample.xsd") or print "cannot remove sample.xsd";
> };

The code looks fine, and I would expect this code to work fine under
linux - what output are you getting?

Just FYI, the reset() call doesn't really do anything - it just sends
a message to any handlers you've registered that they should release
any data they stored as a result of the parse, but since the only
handler you've registered is a PerlErrorHandler it doesn't store any
parse info.

Cheers,
jas.

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






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

Reply via email to