Re: cannot remove file after XercesDOMParser validation
"Bin Yan" <[email protected]>
| Newsgroups | gmane.text.xml.xerces-p.devel |
|---|---|
| Message-ID | <OF83917026.4C0DD86C-ON85256E01.004F2900-85256E01.004F477D@health.state.ny.us> |
Jason: Oops! Didn't read your comment on reset() before I replied to the previous email. Sorry about that. Thanks again. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tony Yan BHNSM NYSDOH Tel: 518-473-1809 Email: [email protected] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Bin Yan" <[email protected] To: [email protected] te.ny.us> cc: Subject: Re: cannot remove file after XercesDOMParser validation 12/19/2003 09:14 AM Please respond to xerces-p-dev 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 jason@openinforma tics.com (Jason To: [email protected] E. Stewart) cc: Sent by: "Jason Subject: Re: cannot remove file after XercesDOMParser validation E. Stewart" <jason@openinform 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.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]