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 Sami Islam <sa...@detewe.de> on 2004/05/18 14:06:45 UTC

Initialization of XMLPlatformUtils in XPathCAPI.cpp

Hello,
Am I correct in thinking that in the XPathCAPI.cpp file the code
snippet: XMLPlatformUtils::Initialize(); initializes XercesC++?
If that is the case then according to the documentation:
****************************************
Use the static initializers to initialize the Xalan-C++ and Xerces-C++
platforms. You must initialize Xerces-C++ once per process. You may
initialize and terminate Xalan-C++ multiple times, but this is not
recommended: it is inefficient and is not thread safe.
****************************************
if one uses the XPathCAPI.cpp and Xerces won't they have problem because
of the initializing taking place twice?

I am using the Xerces API for creating XML Documents and now want to use
Xalan to be able to use XPath to obtain info from the XML file.

I initialize Xerces using XMLPlatformUtils::Initialize(). But now if I
want to use the XalanXPathAPIInitialize( ) then I am in theory
initializing XMLPlatformUtils twice whereas it is only allowed to be
initialize once.

Am I wrong in my thinking?

Regards,
Sami

Re: Initialization of XMLPlatformUtils in XPathCAPI.cpp

Posted by da...@us.ibm.com.
Hi Sami,

> Hello,
> Am I correct in thinking that in the XPathCAPI.cpp file the code snippet:
> XMLPlatformUtils::Initialize(); initializes XercesC++?

Yes

> if one uses the XPathCAPI.cpp and Xerces won't they have problem
> because of the initializing taking place twice?

If you call XalanCAPI XalanXPathAPIInitialize right after you call
PlatformUtils::Initialize(), you will not experience any problems.

> I initialize Xerces using XMLPlatformUtils::Initialize(). But now if I
want
> to use the XalanXPathAPIInitialize( ) then I am in theory initializing
> XMLPlatformUtils twice whereas it is only allowed to be initialize once.

You can call PlatformUtils::Initialize() more than once, you just cannot
call it more than once from multiple threads of execution.

Xalan's XPath C API is incomplete, and is intended for use in C programs.
Since you're already using Xerces-C, which implies your program is written
in C++, it's not clear to me why you're using a C API.  At any rate, since
there is no C API for initializing Xerces-C, XalanXPathAPIInitialize( )
must do it.

By the way, please don't cross-post to both lists.  The C users list is the
appropriate list for these questions.

Dave