if (NS_SUCCEEDED(rv = ds->GetTarget(child, kNC_Name, PR_TRUE, getter_AddRefs(nameNode))))
rv = ds->GetTarget(child, kNC_Name, PR_TRUE, getter_AddRefs(nameNode)); if (NS_SUCCEEDED(rv) && nameNode)
nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds, nsOutputFileStream strm, nsIRDFResource *parent, PRInt32 level){	nsresult	rv = NS_OK;	nsAutoString	indentationString("");	for (PRInt32 loop=0; loop<level; loop++)	indentationString += "    ";	char		*indentation = indentationString.ToNewCString();	if (nsnull == indentation)	return(NS_ERROR_OUT_OF_MEMORY);	nsCOMPtr<nsIRDFContainer> container;	rv = nsComponentManager::CreateInstance(kRDFContainerCID,											nsnull,											nsIRDFContainer::GetIID(),											getter_AddRefs(container));	if (NS_FAILED(rv)) return rv;	rv = container->Init(ds, parent);	if (NS_SUCCEEDED(rv))	{		strm << indentation;		strm << "<DL><p>\n";		nsCOMPtr<nsISimpleEnumerator>	children;		if (NS_SUCCEEDED(rv = container->GetElements(getter_AddRefs(children))))		{			PRBool	more = PR_TRUE;			while (more == PR_TRUE)			{				if (NS_FAILED(rv = children->HasMoreElements(&more)))	break;				if (more != PR_TRUE)	break;				nsCOMPtr<nsISupports>	iSupports;									if (NS_FAILED(rv = children->GetNext(getter_AddRefs(iSupports))))	break;				nsCOMPtr<nsIRDFResource>	child = do_QueryInterface(iSupports);				if (!child)	break;				PRBool	isContainer = PR_FALSE;				if (child.get() != kNC_IEFavoritesRoot)				{					if (NS_SUCCEEDED(rv = gRDFC->IsContainer(ds, child, &isContainer)))					{					}				}				nsCOMPtr<nsIRDFNode>	nameNode;				nsAutoString		nameString("");				char			*name = nsnull;				if (NS_SUCCEEDED(rv = ds->GetTarget(child, kNC_Name, PR_TRUE, getter_AddRefs(nameNode))))				{					nsCOMPtr<nsIRDFLiteral>	nameLiteral = do_QueryInterface(nameNode);					PRUnichar	*title = nsnull;					if (NS_SUCCEEDED(rv = nameLiteral->GetValue(&title)))					{						nameString = title;						name = nameString.ToNewCString();					}										}				strm << indentation;				strm << "    ";				if (isContainer == PR_TRUE)				{					strm << "<DT><H3";					// output ADD_DATE					WriteBookmarkProperties(ds, strm, child, kNC_BookmarkAddDate, kAddDateEquals, PR_FALSE);					// output ID					strm << " " << kIDEquals;					nsXPIDLCString id;					rv = child->GetValue(getter_Copies(id));					if (NS_SUCCEEDED(rv) && (id)) {						strm << (const char*) id;					}					strm << "\"";					strm << ">";					// output title					if (name)	strm << name;					strm << "</H3>\n";					rv = WriteBookmarksContainer(ds, strm, child, level+1);				}				else				{					char	*url = nsnull;					if (NS_SUCCEEDED(rv = child->GetValue(&url)))					{						if (url)						{							nsAutoString	uri(url);							PRBool		isBookmarkSeparator = PR_FALSE;							if (NS_SUCCEEDED(mInner->HasAssertion(child, kRDF_type,								kNC_BookmarkSeparator, PR_TRUE, &isBookmarkSeparator)) &&								(isBookmarkSeparator == PR_TRUE) )							{								// its a separator								strm << "<HR>\n";							}							else							{								strm << "<DT><A HREF=\"";								// output URL								strm << url;								strm << "\"";																	// output ADD_DATE								WriteBookmarkProperties(ds, strm, child, kNC_BookmarkAddDate, kAddDateEquals, PR_FALSE);								// output LAST_VISIT								WriteBookmarkProperties(ds, strm, child, kWEB_LastVisitDate, kLastVisitEquals, PR_FALSE);																	// output LAST_MODIFIED								WriteBookmarkProperties(ds, strm, child, kWEB_LastModifiedDate, kLastModifiedEquals, PR_FALSE);																	// output SHORTCUTURL								WriteBookmarkProperties(ds, strm, child, kNC_ShortcutURL, kShortcutURLEquals, PR_FALSE);																	strm << ">";								// output title								if (name)	strm << name;								strm << "</A>\n";																// output description (if one exists)								WriteBookmarkProperties(ds, strm, child, kNC_Description, kOpenDD, PR_TRUE);							}						}					}				}				if (nsnull != name)				{					delete []name;					name = nsnull;				}									if (NS_FAILED(rv))	break;			}			strm << indentation;			strm << "</DL><p>\n";		}	}	delete [] indentation;	return(rv);}