PRInt32 count = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < count; ++i) { const nsAReadableString& key = aNode.GetKeyAt(i);  nsCOMPtr<nsIAtom> prefix; if (! IsXMLNSDirective(key, getter_AddRefs(prefix))) continue;  nsAutoString uri(aNode.GetValueAt(i)); nsRDFParserUtils::StripAndConvert(uri);   NameSpaceEntry* ns = new NameSpaceEntry(prefix, NS_ConvertUCS2toUTF8(uri).get()); if (! ns) return NS_ERROR_OUT_OF_MEMORY;  ns->mNext = mNameSpaceStack; mNameSpaceStack = ns;   nsCOMPtr<nsIRDFXMLSink> sink = do_QueryInterface(mDataSource); if (sink) sink->AddNameSpace(prefix, uri);
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) { ns = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1); NS_ADDREF(ns); } else { mNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kRDFNameSpaceURI), mRDFNameSpaceID); mNameSpaceManager->CreateRootNameSpace(ns);
RDFContentSinkImpl::PushNameSpacesFrom(const nsIParserNode& aNode){    // Remember the current top of the stack as the namespace    // scope. When popping namespaces, we'll remove stack elements    // until we hit this.    mNameSpaceScopes.AppendElement(mNameSpaceStack);    PRInt32 count = aNode.GetAttributeCount();    for (PRInt32 i = 0; i < count; ++i) {        const nsAReadableString& key = aNode.GetKeyAt(i);        nsCOMPtr<nsIAtom> prefix;        if (! IsXMLNSDirective(key, getter_AddRefs(prefix)))            continue;        nsAutoString uri(aNode.GetValueAt(i));        nsRDFParserUtils::StripAndConvert(uri);        // Open a local namespace        NameSpaceEntry* ns = new NameSpaceEntry(prefix, NS_ConvertUCS2toUTF8(uri).get());        if (! ns)            return NS_ERROR_OUT_OF_MEMORY;        ns->mNext = mNameSpaceStack;        mNameSpaceStack = ns;        // Add it to the set of namespaces used in the RDF/XML document.        nsCOMPtr<nsIRDFXMLSink> sink = do_QueryInterface(mDataSource);        if (sink)            sink->AddNameSpace(prefix, uri);    }    return NS_OK;}