if (gRefCnt == 0) { kContainerAtom             = NS_NewAtom("container"); kItemContentsGeneratedAtom = NS_NewAtom("itemcontentsgenerated");  kIdAtom              = NS_NewAtom("id"); kOpenAtom            = NS_NewAtom("open"); kResourceAtom        = NS_NewAtom("resource"); kNaturalOrderPosAtom = NS_NewAtom("pos"); kContainmentAtom     = NS_NewAtom("containment");  nsresult rv;    if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager))) {   static const char kXULNameSpaceURI[] = "http:  static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;  rv = gNameSpaceManager->RegisterNameSpace(kXULNameSpaceURI, kNameSpaceID_XUL); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace");  rv = gNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, kNameSpaceID_RDF); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace"); } else { NS_ERROR("couldn't create namepsace manager"); }     rv = nsServiceManager::GetService(kRDFServiceCID, kIRDFServiceIID, (nsISupports**) &gRDFService);  if (NS_FAILED(rv)) { NS_ERROR("couldnt' get RDF service"); }  NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Title,  &kNC_Title)), "couldn't get resource");  NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_child,  &kNC_child)), "couldn't get resource");  NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Column, &kNC_Column)), "couldn't get resource");  NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Folder,  &kNC_Folder)), "couldn't get resource");  NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURIRDF_child,  &kRDF_child)), "couldn't get resource");  } ++gRefCnt;
RDFGenericBuilderImpl::RDFGenericBuilderImpl(void)    : mDocument(nsnull),      mDB(nsnull),      mRoot(nsnull),      mTimer(nsnull){    NS_INIT_REFCNT();    if (gRefCnt == 0) {        kContainerAtom             = NS_NewAtom("container");        kItemContentsGeneratedAtom = NS_NewAtom("itemcontentsgenerated");        kIdAtom              = NS_NewAtom("id");        kOpenAtom            = NS_NewAtom("open");        kResourceAtom        = NS_NewAtom("resource");        kNaturalOrderPosAtom = NS_NewAtom("pos");        kContainmentAtom     = NS_NewAtom("containment");        nsresult rv;        // Register the XUL and RDF namespaces: these'll just retrieve        // the IDs if they've already been registered by someone else.        if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,                                                           nsnull,                                                           kINameSpaceManagerIID,                                                           (void**) &gNameSpaceManager))) {// XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cppstatic const char kXULNameSpaceURI[]    = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";static const char kRDFNameSpaceURI[]    = RDF_NAMESPACE_URI;            rv = gNameSpaceManager->RegisterNameSpace(kXULNameSpaceURI, kNameSpaceID_XUL);            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace");            rv = gNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, kNameSpaceID_RDF);            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace");        }        else {            NS_ERROR("couldn't create namepsace manager");        }        // Initialize the global shared reference to the service        // manager and get some shared resource objects.        rv = nsServiceManager::GetService(kRDFServiceCID,                                          kIRDFServiceIID,                                          (nsISupports**) &gRDFService);        if (NS_FAILED(rv)) {            NS_ERROR("couldnt' get RDF service");        }        NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Title,  &kNC_Title)),                  "couldn't get resource");        NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_child,  &kNC_child)),                  "couldn't get resource");        NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Column, &kNC_Column)),                  "couldn't get resource");        NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURINC_Folder,  &kNC_Folder)),                  "couldn't get resource");        NS_VERIFY(NS_SUCCEEDED(gRDFService->GetResource(kURIRDF_child,  &kRDF_child)),                  "couldn't get resource");    }    ++gRefCnt;}