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 "Tankel, Ifat" <If...@icomverse.com> on 2002/06/23 09:51:26 UTC

RE: creating a thread safe class which use the xalan/xercess to a ccess/modify data written in xml format

Way can't  I make 
DOMParser * _domParser; XercesDOMSupport  *  _domSupport; and
XercesParserLiaison *  _parserLiaison;
as class members of myDom class.

Then after initializing Xerces and Xalan create them (on the heap) using
new DOMParser, new XercessDOMSuport, new XercessParserLiaison().

And before terminating Xecress and Xalan delete them from the heap.

ifat

-----Original Message-----
From: David N Bertoni/Cambridge/IBM [mailto:david_n_bertoni@us.ibm.com]
Sent: Thursday, June 20, 2002 6:34 PM
To: 'xalan-c-users@xml.apache.org'
Subject: 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