nsCOMPtr<nsINameSpaceManager> mgr = do_CreateInstance(kNameSpaceManagerCID); if (mgr) { rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace"); rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), kNameSpaceID_RDF); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace"); } else NS_ERROR("couldn't create namepsace manager");
XULSortServiceImpl::XULSortServiceImpl(void){  NS_INIT_ISUPPORTS();  if (gRefCnt == 0) {    kStaticHintAtom = NS_NewAtom("staticHint");    kStaticsSortLastHintAtom   = NS_NewAtom("sortStaticsLast");    kResourceAtom = NS_NewAtom("resource");    kSortResourceAtom = NS_NewAtom("sortResource");    kSortResource2Atom = NS_NewAtom("sortResource2");    kSortSeparatorsAtom = NS_NewAtom("sortSeparators");    kRDF_type = NS_NewAtom("type");     kTrueStr = new nsString(NS_LITERAL_STRING("true"));    kNaturalStr = new nsString(NS_LITERAL_STRING("natural"));    kAscendingStr = new nsString(NS_LITERAL_STRING("ascending"));    kDescendingStr = new nsString(NS_LITERAL_STRING("descending"));     nsresult rv = nsServiceManager::GetService(kRDFServiceCID,                                               NS_GET_IID(nsIRDFService),                                               (nsISupports**) &gRDFService);    if (NS_FAILED(rv))      NS_ERROR("couldn't create rdf service");    rv = nsServiceManager::GetService(kRDFContainerUtilsCID,                                      NS_GET_IID(nsIRDFContainerUtils),                                      (nsISupports**) &gRDFC);    if (NS_FAILED(rv))      NS_ERROR("couldn't create rdf container utils");    // get a locale service     nsCOMPtr<nsILocaleService> localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);    if (NS_SUCCEEDED(rv)) {      nsCOMPtr<nsILocale>  locale;      if (NS_SUCCEEDED(rv = localeService->GetApplicationLocale(getter_AddRefs(locale))) && (locale)) {        nsCOMPtr<nsICollationFactory> colFactory = do_CreateInstance(kCollationFactoryCID);        if (colFactory) {          if (NS_FAILED(rv = colFactory->CreateCollation(locale, &gCollation)))            NS_ERROR("couldn't create collation instance");        } else          NS_ERROR("couldn't create instance of collation factory");      } else        NS_ERROR("unable to get application locale");    } else      NS_ERROR("couldn't get locale factory");    // Register the XUL and RDF namespaces: these'll just retrieve    // the IDs if they've already been registered by someone else.    nsCOMPtr<nsINameSpaceManager> mgr = do_CreateInstance(kNameSpaceManagerCID);    if (mgr) {      rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kXULNameSpaceURI), kNameSpaceID_XUL);      NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace");      rv = mgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), kNameSpaceID_RDF);      NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace");    } else      NS_ERROR("couldn't create namepsace manager");  }  ++gRefCnt;}