I ran an additional test with a mangled XML file (not well formed), a fatal error was reported (expected), and an exception was thrown (expected) but then I immediately tried to delete the file but could not. Correct me if I am wrong but this seems like a bug, the XMLReader should release the file reference so that the file can be accessed. From what I am seeing if an exception occurs while parsing with SAX the file then becomes "locked" and cannot be used by the client application.
Thanks, Rob -----Original Message----- From: Rob Outar [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 2:50 PM To: [EMAIL PROTECTED] Subject: RE: XMLReader not releasing file reference I was hoping this was not going to be complex, but why when I throw an exception to abort parsing the XMLReader class is not closing file references? Thanks, Rob -----Original Message----- From: Rob Outar [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 2:17 PM To: [EMAIL PROTECTED] Subject: RE: XMLReader not releasing file reference Using the below: private static final String PARSER_NAME = "org.apache.xerces.parsers.SAXParser"; private static final String NONVALIDATING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; parser = XMLReaderFactory.createXMLReader(PARSER_NAME); parser.setFeature(NONVALIDATING_FEATURE, false); Thanks, Rob -----Original Message----- From: Peter McCracken [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 2:07 PM To: [EMAIL PROTECTED] Subject: RE: XMLReader not releasing file reference Hi, I traced through what happens when a SAXException is thrown on one of the pre-built pipelines (XML11Configuration), it seems that the readers are closed in a finally block of DTDConfiguration#parse(XMLInputSource). Which pipeline configuration are you using? Since you're only concerned with preprocessing instructions and don't need DTD validation, I'm guessing that you're not using a pipeline configuration which is derived from DTDConfiguration. Thus, it would be up to you to close the readers in your custom pipeline. You need to call closeReaders() on the EntityManager in the pipeline. Take a look at DTDConfiguration#parse and DTDConfiguration#cleanup. However, this doesn't explain why it's only happening with big files. I'm at a loss, there. Cheers, Peter McCracken/Toronto/IBM "Rob Outar" <[EMAIL PROTECTED] To: <[EMAIL PROTECTED]> o.org> cc: Subject: RE: XMLReader not releasing file reference 08/12/2003 12:12 PM Please respond to xerces-j-user Update: Tried a 20kb file and the same problem. Seems like whenever a SAXException is thrown the Xerces SAXParser does not release the reference to the file. We saw when the files were tiny, 5kb or so those seem to be okay. Thanks, Rob -----Original Message----- From: Rob Outar [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 11:15 AM To: [EMAIL PROTECTED] Subject: XMLReader not releasing file reference Hi all, I have an application that only needs to read preprocessing instructions from an XML file. Since I am only interested in Processing Instructions when I encounter the start element I throw a SAX Exception to abort parsing: public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { throw new SAXException("Abort Parsing"); Once this exception is encountered by the client application I then try to delete the XML file, some of the XML files I read can be deleted while others cannot. The problem seems to occur on large files ( > 200kb ).... Is there any reason the XMLReader would maintain the file reference? I am not sure what is happening as I mentioned usually all of the smaller files are deleted just fine but larger ones seem to have a file reference and File.delete() fails (return false). Any help would be appreciated. Thanks, Rob --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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]