BookmarkParser::ParseBookmarkHeader(const nsString& aLine, nsCOMPtr<nsIRDFContainer>& aContainer,
BookmarkParser::ParseBookmarkHeader(const nsString &aLine, const nsCOMPtr<nsIRDFContainer> &aContainer,
BookmarkParser::ParseBookmarkHeader(const nsString& aLine,				    nsCOMPtr<nsIRDFContainer>& aContainer,				    nsIRDFResource *nodeType){	// Snip out the header	PRInt32 start = aLine.Find(kOpenHeading, PR_TRUE);	NS_ASSERTION(start >= 0, "couldn't find '<H'; why am I here?");	if (start < 0)		return NS_ERROR_UNEXPECTED;	start += (sizeof(kOpenHeading) - 1);	start = aLine.FindChar(PRUnichar('>'), PR_FALSE,start); // skip to the end of the '<Hn>' tag	if (start < 0) {		NS_WARNING("couldn't find end of header tag");		return NS_OK;	}	nsAutoString name;	aLine.Right(name, aLine.Length() - (start + 1));	PRInt32 end = name.Find(kCloseHeading, PR_TRUE);	if (end < 0)		NS_WARNING("No '</H' found to close the heading");	if (end >= 0)		name.Truncate(end);	// Find the add date	PRInt32 addDate = 0;	nsAutoString s;	ParseAttribute(aLine, kAddDateEquals, sizeof(kAddDateEquals) - 1, s);	if (s.Length() > 0) {		PRInt32 err;		addDate = s.ToInteger(&err); // ignored	}	// Find the lastmod date	PRInt32 lastmodDate = 0;	ParseAttribute(aLine, kLastModifiedEquals, sizeof(kLastModifiedEquals) - 1, s);	if (s.Length() > 0) {		PRInt32 err;		lastmodDate = s.ToInteger(&err); // ignored	}	nsAutoString id;	ParseAttribute(aLine, kIDEquals, sizeof(kIDEquals) - 1, id);	// Make the necessary assertions	nsresult rv;	nsCOMPtr<nsIRDFResource> folder;	if (id.Length() > 0) {		// Use the ID attribute, if one is set.		rv = gRDF->GetUnicodeResource(id.GetUnicode(), getter_AddRefs(folder));		NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create resource for folder");		if (NS_FAILED(rv)) return rv;	}	else if (name.Equals(kPersonalToolbarFolder)) { // XXX I18n!!!		folder = dont_QueryInterface( kNC_PersonalToolbarFolder );	}	else {		// We've never seen this folder before. Assign it an anonymous ID		rv = CreateAnonymousResource(&folder);		NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create anonymous resource for folder");		if (NS_FAILED(rv)) return rv;	}	nsCOMPtr<nsIRDFLiteral> literal;	rv = gRDF->GetLiteral(name.GetUnicode(), getter_AddRefs(literal));	NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create literal for folder name");	if (NS_FAILED(rv)) return rv;	rv = mDataSource->Assert(folder, kNC_Name, literal, PR_TRUE);	if (rv != NS_RDF_ASSERTION_ACCEPTED) {		NS_ERROR("unable to set folder name");		return rv;	}	rv = gRDFC->MakeSeq(mDataSource, folder, nsnull);	NS_ASSERTION(NS_SUCCEEDED(rv), "unable to make new folder as sequence");	if (NS_FAILED(rv)) return rv;	rv = mDataSource->Assert(folder, kRDF_type, kNC_Folder, PR_TRUE);	if (rv != NS_RDF_ASSERTION_ACCEPTED) {		NS_ERROR("unable to mark new folder as folder");		return rv;	}	if (NS_FAILED(rv = AssertTime(folder, kNC_BookmarkAddDate, addDate))) {		NS_ERROR("unable to mark add date");		return rv;	}	if (NS_FAILED(rv = AssertTime(folder, kWEB_LastModifiedDate, lastmodDate))) {		NS_ERROR("unable to mark lastmod date");		return rv;	}	// And now recursively parse the rest of the file...	if (NS_FAILED(rv = Parse(folder, nodeType))) {		NS_WARNING("recursive parse of bookmarks file failed");		return rv;	}	// rjc: always do this last	rv = aContainer->AppendElement(folder);	NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add folder to container");	if (NS_FAILED(rv)) return rv;	return NS_OK;}