nsAutoString	indentationString(""); for (PRInt32 loop=0; loop<level; loop++)	indentationString += "    "; char		*indentation = indentationString.ToNewCString(); if (nsnull == indentation)	return(NS_ERROR_OUT_OF_MEMORY);
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,		NS_GET_IID(nsIRDFContainer), 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)				{					rv = gRDFC->IsContainer(ds, child, &isContainer);					if (NS_FAILED(rv)) break;				}				nsCOMPtr<nsIRDFNode>	nameNode;				nsAutoString		nameString("");				char			*name = nsnull;				rv = ds->GetTarget(child, kNC_Name, PR_TRUE, getter_AddRefs(nameNode));				if (NS_SUCCEEDED(rv) && nameNode)				{					nsCOMPtr<nsIRDFLiteral>	nameLiteral = do_QueryInterface(nameNode);					if (nameLiteral)					{						const PRUnichar	*title = nsnull;						if (NS_SUCCEEDED(rv = nameLiteral->GetValueConst(&title)))						{							nameString = title;							name = nameString.ToNewUTF8String();						}					}				}				strm << indentation;				strm << "    ";				if (isContainer == PR_TRUE)				{					strm << "<DT><H3";					// output ADD_DATE					WriteBookmarkProperties(ds, strm, child, kNC_BookmarkAddDate, kAddDateEquals, PR_FALSE);					// output LAST_MODIFIED					WriteBookmarkProperties(ds, strm, child, kWEB_LastModifiedDate, kLastModifiedEquals, PR_FALSE);					// output ID					strm << " " << kIDEquals;					const char	*id = nsnull;					rv = child->GetValueConst(&id);					if (NS_SUCCEEDED(rv) && (id)) {						strm << (const char*) id;					}					strm << "\"";					strm << ">";					// output title					if (name)	strm << name;					strm << "</H3>\n";					// output description (if one exists)					WriteBookmarkProperties(ds, strm, child, kNC_Description, kOpenDD, PR_TRUE);					rv = WriteBookmarksContainer(ds, strm, child, level+1);				}				else				{					const char	*url = nsnull;					if (NS_SUCCEEDED(rv = child->GetValueConst(&url)) && (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);							// output SCHEDULE							WriteBookmarkProperties(ds, strm, child, kWEB_Schedule, kScheduleEquals, PR_FALSE);							// output LAST_PING							WriteBookmarkProperties(ds, strm, child, kWEB_LastPingDate, kLastPingEquals, PR_FALSE);							// output PING_ETAG							WriteBookmarkProperties(ds, strm, child, kWEB_LastPingETag, kPingETagEquals, PR_FALSE);							// output PING_LAST_MODIFIED							WriteBookmarkProperties(ds, strm, child, kWEB_LastPingModDate, kPingLastModEquals, PR_FALSE);							// output PING_CONTENT_LEN							WriteBookmarkProperties(ds, strm, child, kWEB_LastPingContentLen, kPingContentLenEquals, PR_FALSE);							// output PING_STATUS							WriteBookmarkProperties(ds, strm, child, kWEB_Status, kPingStatusEquals, PR_FALSE);							strm << ">";							// output title							if (name)							{								// Note: we escape the title due to security issues;								//       see bug # 13197 for details								char *escapedAttrib = nsEscapeHTML(name);								if (escapedAttrib)								{									strm << escapedAttrib;									nsCRT::free(escapedAttrib);									escapedAttrib = nsnull;								}							}							strm << "</A>\n";														// output description (if one exists)							WriteBookmarkProperties(ds, strm, child, kNC_Description, kOpenDD, PR_TRUE);						}					}				}				if (nsnull != name)				{					nsCRT::free(name);					name = nsnull;				}									if (NS_FAILED(rv))	break;			}			strm << indentation;			strm << "</DL><p>\n";		}	}	nsCRT::free(indentation);	return(rv);}