Hi Nikolay, nikolayo <[EMAIL PROTECTED]> wrote on 10/13/2008 04:15:54 AM:
> Thank you, Michael. I realize that this is more of a DOM problem rather than > Xerces problem (and BTW - thank you and everybody out there for Xerces) but Xerces > is an influential product and Xerces developers must be some of the best DOM > experts that there are. So if you do not mind the question : what is your > take on using DOM documents in multi-threaded environment? In general you need to be careful and synchronize your code such that no more than one thread accesses a DOM instance at a time. You need to do this because the DOM specification says nothing about thread-safety. In order to ensure your application will work with any DOM implementation you must assume the worst case. If your application doesn't need to work with arbitrary DOM implementations (and don't mind tying it to a specific implementation) you could select one which guarantees thread-safety for read, write or some set of methods (I don't know of one which has such guarantees) and synchronize more optimistically or not at all if the DOM implementation you're using allows you to do that. > If general DOM discussion is off topic for you, I can also narrow this down to : > what is the safe bet for cloning of documents in Xerces so that it is safe to use > clones in different threads? In Xerces I'm pretty sure a cloned Document is completely disconnected from the original with possibly the exception of user data [1] your application may have copied over. It should generally be safe to use it in a different thread than the original Document. > Regards > Nikolay Thanks. [1] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#UserDataHandler Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED]