You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ja...@lotus.com on 2000/01/11 19:45:58 UTC

xalan-c Problem with Xerces initialization


When working with Xalan-c on Linux, I found that even if the
XMLPlatformUtils::Initialize() method is called directly from the main
program, there is still the possibility of making calls to getDOMConverter
when creating statically initialized variables, long before main starts
execution.

I managed to get around this by adding a call to
XMLPlatformUtils::Initialize() in the getDOMConverter method in
DOMString.cpp:

XMLLCPTranscoder*  getDomConverter()
{
    static XMLLCPTranscoder* gDomConverter = 0;
    if (!gDomConverter)
    {
      // Make sure we've been initialized
      XMLPlatformUtils::Initialize();
        XMLLCPTranscoder* transcoder =
        XMLPlatformUtils::fgTransService->makeNewLCPTranscoder();
        if (!transcoder)
            XMLPlatformUtils::panic(XMLPlatformUtils::Panic_NoDefTranscoder
            );

        if (XMLPlatformUtils::compareAndSwap((void **)&gDomConverter,
        transcoder, 0) != 0)
            delete gDomConverter;
    }
    return gDomConverter;
};

If the DOM converter has already been called, then this code will not be
executed again, and if the Initialize method had already been called, it
just returns, so this has minimal overhead.  I'd like to suggest that this
patch be incorporated into Xerces.




Jack Donohue