You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by David N Bertoni/Cambridge/IBM <da...@us.ibm.com> on 2002/06/20 17:33:40 UTC

Re: createing a thread safe class which use the xalan/xercess to access/modify data written in xml format

It's a very bad idea to have these as static data members.  Not only will
it not be thread-safe, but you'll have to make sure they are not
constructed until you initialize Xerces and Xalan, and that they are
destroyed before you terminate.  That's extremely difficult to do.

You should make the XercesDOMSupport and XercesParserLiaison instances
classes members.  The parser you can create on the stack and let it be
destroyed after you parse the document.

Dave



                                                                                                                               
                      "Tankel, Ifat"                                                                                           
                      <Ifat_Tankel@ico         To:      "'xalan-c-users@xml.apache.org'" <xa...@xml.apache.org>        
                      mverse.com>              cc:      (bcc: David N Bertoni/Cambridge/IBM)                                   
                                               Subject: createing a thread safe class which use the xalan/xercess to acce      
                      06/20/2002 07:41         ss/modify data written in xml format                                            
                      AM                                                                                                       
                                                                                                                               
                                                                                                                               



Hi
I have created a class myDom.
This class is to be used by other classes when they need to access/modify
data written in xml format (file or buffer).
The init method of my myDom class take a xml buffer/file and use a
DOMParser and XercessParserLiaison to create a XalanDocument.


Can I create DomPareser and XercessDOMSupport and XercessParserLiaison as
static members of myDom class?
I do not want to create them in each myDom instance since they are used
only in the init stage.


My application will have to be thread safe. Do I have a problem to create
them static because of that?


Ifat