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/05/29 18:10:46 UTC
Re: "working with Dom input and output" pattern but with DOM objects
created with NEW
You can create a DOM_Document instance with new, but you shouldn't. It
will work, but it defeats the purpose of DOM_Document, which is a
smart-pointer to an underlying implementation instance. If you do this,
you must make sure you _never_ make a copy of the pointer, which is a
difficult promise to keep.
It's best to ask questions related solely to Xerces on the Xerces-C list.
Dave
"Tankel, Ifat"
<Ifat_Tankel@ico To: xalan-c-users@xml.apache.org
mverse.com> cc: (bcc: David N Bertoni/Cambridge/IBM)
Subject: "working with Dom input and output" pattern but with DOM objects
05/28/2002 10:39 created with NEW
PM
Hi,
I am using the first part of usage pattern named "working with Dom input
and output"
to create a XalanDocument. This is done in an init method of a class I
wrote (in c++)
// some of the members of my class
static DOMParser *_domParser;
static XercesParserLiaison * _parserLiaison;
DOM_Document * _domDocument;
XalanDocument * _xalanReelDoc;
// initiating the class members
_domParser=new DOMParser();
_parserLiaison = new XercesParserLiaison();
_domDocument =new DOMDocument();
_domParser->parse( xmlfileSource);
*_domDocument= _domParser->getDocument();
_xalanRealDoc= _parserLiaison->createDocument(*_domDocument)
The difference is that I use "new" to create the DOMParser,
XercesParserLiaison and DOMDocument.
I wrote a program that use this class and everything works.
but then I entered Xercess DOM programming guide and I read this:
"Never "new" a DOM object into the heap or make an ordinary C pointer
variable to one, as this will greatly confuse the automatic memory
management.
way "newing" a DOM object do that ?
will I get an exception when this happened?
Ifat
ifat.tankel@comverse.com
Comverse Divisional Developer