[From nobody Fri Aug 6 17:07:27 2004 Return-Path: <kgillies@gemini.edu> Received: from alias.acm.org ([199.222.69.90]) by bissell.mail.mindspring.net (Earthlink Mail Service) with ESMTP id 16Kzgk1FD3Nl3rE0 for <servlets@mindspring.com>; Mon, 11 Mar 2002 18:31:28 -0500 (EST) Received: from cygnus.hi.gemini.edu (128.171.188.208) by alias.acm.org with MERCUR Mailserver (v4.01.11 OTAtMjE3Ni00NjIw) for <servlets@mindspring.com>; Mon, 11 Mar 2002 18:27:54 -0500 Received: from localhost (dhcp1-132 [192.168.1.132]) by cygnus.hi.gemini.edu (Pro-8.9.3/Pro-8.9.3) with ESMTP id NAA01868 for <jhunter@acm.org>; Mon, 11 Mar 2002 13:28:15 -1000 (HST) Date: Mon, 11 Mar 2002 16:28:14 -0700 Mime-Version: 1.0 (Apple Message framework v481) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: JDOM ? From: "K.Gillies" <kgillies@gemini.edu> To: jhunter@acm.org Content-Transfer-Encoding: 7bit Message-Id: <A8965ECC-3547-11D6-A411-00039340AA82@gemini.edu> X-Mailer: Apple Mail (2.481) X-Mozilla-Status2: 00000000 Hi Jason, I apologize for writing you directly. I'm not a regular watcher of the JDOM lists although I'm use JDOM -- and I like it! So if you like, please give me advice. I have an application that reads many XML files that must be validated to several DTDs. Someone suggested that creating XML parsers and configuring every time a new file must be parsed was rather expensive and that parsers should be cached like JDBC connections are often cached. A new parser isn't needed for every document. I didn't do any measurements since it seemed like a reasonable statement. So I built a class to provide a central cache of SAXBuilders (one to start with) and allowed clients of the cache to add EntityResolver instances to locally return entities. My single EntityResolver just goes through all the client EntityResolvers one by one. All was good until I tried parsing multiple documents, then I got a JDOMException "Error in building: Stream closed" I then went to the SAXBuilder source to look around. What I found is that SAXBuilder always creates a new parser in the build method. So all my efforts were misplaced. It appears that SAXBuilder can't be resued. Do you have any comments on this? Shouldn't I be concerned about the cost of creating/configuring parsers every time a new document must be parsed? One case where this seems important is a web service that needs to handle XML messages (like a service using SOAP). Is there a way to reuse a SAXBuilder and not create a new parser for every document? Thanks for any advice you have. Kim Gillies ]