mInner->Assert(res, kNC_Date, dateLiteral, PR_TRUE); hasDateFlag = PR_TRUE;
relStr.Cut(x, 1);
InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *mEngine,				const PRUnichar *htmlPage){	// get data out of graph	nsresult	rv;	nsCOMPtr<nsIRDFNode>	dataNode;	if (NS_FAILED(rv = mInner->GetTarget(mEngine, kNC_Data, PR_TRUE, getter_AddRefs(dataNode))))	{		return(rv);	}	nsCOMPtr<nsIRDFLiteral>	dataLiteral (do_QueryInterface(dataNode));	if (!dataLiteral)	return(NS_ERROR_NULL_POINTER);	const PRUnichar	*dataUni = nsnull;	if (NS_FAILED(rv = dataLiteral->GetValueConst(&dataUni)))		return(rv);	if (!dataUni)	return(NS_ERROR_NULL_POINTER);	// get name of this engine once	nsAutoString	engineStr;	GetData(dataUni, "search", 0, "name", engineStr);	// pre-compute host (we might discard URLs that match this)	nsAutoString	hostStr;	char		*hostName = nsnull;	aURL->GetHost(&hostName);	if (hostName)	{		hostStr.AssignWithConversion(hostName);		nsCRT::free(hostName);		hostName = nsnull;	}	// pre-compute server path (we might discard URLs that match this)	nsAutoString	serverPathStr;	char *serverPath = nsnull;	aURL->GetPath(&serverPath);	if (serverPath)	{		serverPathStr.AssignWithConversion(serverPath);		nsCRT::free(serverPath);		serverPath = nsnull;		PRInt32 serverOptionsOffset = serverPathStr.FindChar(PRUnichar('?'));		if (serverOptionsOffset >= 0)	serverPathStr.Truncate(serverOptionsOffset);	}	PRBool		hasPriceFlag = PR_FALSE, hasAvailabilityFlag = PR_FALSE, hasRelevanceFlag = PR_FALSE;	PRBool		hasDateFlag = PR_FALSE;	PRBool		skipLocalFlag = PR_FALSE, useAllHREFsFlag = PR_FALSE;	PRInt32		pageRank = 1;	PRUint32	numInterpretSections, numResults = 0;	GetNumInterpretSections(dataUni, numInterpretSections);	if (numInterpretSections < 1)	{		// if no <interpret> sections, use all the HREFS on the page		numInterpretSections = 1;		useAllHREFsFlag = PR_TRUE;		skipLocalFlag = PR_TRUE;	}	// need to handle multiple <interpret> sections, per spec	for (PRUint32 interpretSectionNum=0; interpretSectionNum < numInterpretSections; interpretSectionNum++)	{		nsAutoString	resultListStartStr, resultListEndStr;		nsAutoString	resultItemStartStr, resultItemEndStr;		nsAutoString	relevanceStartStr, relevanceEndStr;		nsAutoString	bannerStartStr, bannerEndStr, skiplocalStr;		nsAutoString	priceStartStr, priceEndStr, availStartStr, availEndStr;		nsAutoString	dateStartStr, dateEndStr;		nsAutoString	nameStartStr, nameEndStr;		nsAutoString	emailStartStr, emailEndStr;		nsAutoString	browserResultTypeStr;		browserResultTypeStr.AssignWithConversion("result");		// default to "result"		// need an original copy of the HTML every time through the loop		nsAutoString	htmlResults(htmlPage);		if (useAllHREFsFlag == PR_FALSE)		{			GetData(dataUni, "interpret", interpretSectionNum, "resultListStart", resultListStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "resultListEnd", resultListEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "resultItemStart", resultItemStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "resultItemEnd", resultItemEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "relevanceStart", relevanceStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "relevanceEnd", relevanceEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "bannerStart", bannerStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "bannerEnd", bannerEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "skiplocal", skiplocalStr);			skipLocalFlag = (skiplocalStr.EqualsIgnoreCase("true")) ? PR_TRUE : PR_FALSE;			// shopping channel support			GetData(dataUni, "interpret", interpretSectionNum, "priceStart", priceStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "priceEnd", priceEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "availStart", availStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "availEnd", availEndStr);			// news channel support			GetData(dataUni, "interpret", interpretSectionNum, "dateStart", dateStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "dateEnd", dateEndStr);			// people channel support			GetData(dataUni, "interpret", interpretSectionNum, "nameStart", nameStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "nameEnd", nameEndStr);			GetData(dataUni, "interpret", interpretSectionNum, "emailStart", emailStartStr);			GetData(dataUni, "interpret", interpretSectionNum, "emailEnd", emailEndStr);			// special browser support			GetData(dataUni, "interpret", interpretSectionNum, "browserResultType", browserResultTypeStr);			if (browserResultTypeStr.Length() < 1)			{				browserResultTypeStr.AssignWithConversion("result");	// default to "result"			}		}		// look for banner		nsCOMPtr<nsIRDFLiteral>	bannerLiteral;		if ((bannerStartStr.Length() > 0) && (bannerEndStr.Length() > 0))		{			PRInt32	bannerStart = htmlResults.Find(bannerStartStr, PR_TRUE);			if (bannerStart >= 0)			{				PRInt32	bannerEnd = htmlResults.Find(bannerEndStr, PR_TRUE, bannerStart + bannerStartStr.Length());				if (bannerEnd > bannerStart)				{					nsAutoString	htmlBanner;					htmlResults.Mid(htmlBanner, bannerStart, bannerEnd - bannerStart - 1);					if (htmlBanner.Length() > 0)					{						const PRUnichar	*bannerUni = htmlBanner.get();						if (bannerUni)						{							gRDFService->GetLiteral(bannerUni, getter_AddRefs(bannerLiteral));						}					}				}			}		}		if (resultListStartStr.Length() > 0)		{			PRInt32	resultListStart = htmlResults.Find(resultListStartStr, PR_TRUE);			if (resultListStart >= 0)			{				htmlResults.Cut(0, resultListStart + resultListStartStr.Length());			}			else if (useAllHREFsFlag == PR_FALSE)			{				// if we have multiple <INTERPRET> sections but can't find the start				// of a result list block, just continue on with the the next block				continue;			}		}		if (resultListEndStr.Length() > 0)		{			// rjc note: use RFind to find the LAST occurrence of resultListEndStr			PRInt32	resultListEnd = htmlResults.RFind(resultListEndStr, PR_TRUE);			if (resultListEnd >= 0)			{				htmlResults.Truncate(resultListEnd);			}		}		PRBool	trimItemStart = PR_TRUE;		PRBool	trimItemEnd = PR_FALSE;		// rjc note: testing shows we should NEVER trim end???		// if resultItemStartStr is not specified, try making it just be "HREF="		if (resultItemStartStr.Length() < 1)		{			resultItemStartStr.AssignWithConversion("HREF=");			trimItemStart = PR_FALSE;		}		// if resultItemEndStr is not specified, try making it the same as resultItemStartStr		if (resultItemEndStr.Length() < 1)		{			resultItemEndStr = resultItemStartStr;			trimItemEnd = PR_TRUE;		}		while(PR_TRUE)		{			PRInt32	resultItemStart;			resultItemStart = htmlResults.Find(resultItemStartStr, PR_TRUE);			if (resultItemStart < 0)	break;			PRInt32	resultItemEnd;			if (trimItemStart == PR_TRUE)			{				htmlResults.Cut(0, resultItemStart + resultItemStartStr.Length());				resultItemEnd = htmlResults.Find(resultItemEndStr, PR_TRUE );			}			else			{				htmlResults.Cut(0, resultItemStart);				resultItemEnd = htmlResults.Find(resultItemEndStr, PR_TRUE, resultItemStartStr.Length() );			}			if (resultItemEnd < 0)			{				resultItemEnd = htmlResults.Length()-1;			}			else if ((trimItemEnd == PR_FALSE) && (resultItemEnd >= 0))			{				resultItemEnd += resultItemEndStr.Length();			}			nsAutoString	resultItem;			htmlResults.Left(resultItem, resultItemEnd);			if (resultItem.Length() < 1)	break;			htmlResults.Cut(0, resultItemEnd);#ifdef	DEBUG_SEARCH_OUTPUT			char	*results = ToNewCString(resultItem);			if (results)			{				printf("\n----- Search result: '%s'\n\n", results);				nsCRT::free(results);				results = nsnull;			}#endif			// look for href			PRInt32	hrefOffset = resultItem.Find("HREF=", PR_TRUE);			if (hrefOffset < 0)			{#ifdef	DEBUG_SEARCH_OUTPUT				printf("\n***** Unable to find HREF!\n\n");#endif				continue;			}			nsAutoString	hrefStr;			PRInt32		quoteStartOffset = resultItem.FindCharInSet("\"\'>", hrefOffset);			PRInt32		quoteEndOffset;			if (quoteStartOffset < hrefOffset)			{				// handle case where HREF isn't quoted				quoteStartOffset = hrefOffset + nsCRT::strlen("HREF=");				quoteEndOffset = resultItem.FindCharInSet(">", quoteStartOffset);				if (quoteEndOffset < quoteStartOffset)	continue;			}			else			{				if (resultItem[quoteStartOffset] == PRUnichar('>'))				{					// handle case where HREF isn't quoted					quoteEndOffset = quoteStartOffset;					quoteStartOffset = hrefOffset + nsCRT::strlen("HREF=") -1;				}				else				{					quoteEndOffset = resultItem.FindCharInSet("\"\'", quoteStartOffset + 1);					if (quoteEndOffset < hrefOffset)	continue;				}			}			resultItem.Mid(hrefStr, quoteStartOffset + 1, quoteEndOffset - quoteStartOffset - 1);			// strip out any bogus CRs or LFs from the HREF URL			PRInt32		crlfOffset;			while ((crlfOffset = hrefStr.FindCharInSet("\n\r", 0)) >= 0)			{				hrefStr.Cut(crlfOffset, 1);			}			if (hrefStr.Length() < 1)	continue;			char		*absURIStr = nsnull;			nsCAutoString	hrefstrC;			hrefstrC.AssignWithConversion(hrefStr);			if (NS_SUCCEEDED(rv = NS_MakeAbsoluteURI(&absURIStr, hrefstrC.get(), aURL))			    && (absURIStr))			{				hrefStr.AssignWithConversion(absURIStr);				nsCOMPtr<nsIURI>	absURI;				rv = NS_NewURI(getter_AddRefs(absURI), absURIStr);				nsCRT::free(absURIStr);				absURIStr = nsnull;				if ((absURI) && (skipLocalFlag == PR_TRUE))				{					char	*absPath = nsnull;					absURI->GetPath(&absPath);					if (absPath)					{						nsAutoString	absPathStr;						absPathStr.AssignWithConversion(absPath);						nsCRT::free(absPath);						PRInt32 pathOptionsOffset = absPathStr.FindChar(PRUnichar('?'));						if (pathOptionsOffset >= 0)							absPathStr.Truncate(pathOptionsOffset);						PRBool	pathsMatchFlag = serverPathStr.EqualsIgnoreCase(absPathStr);						if (pathsMatchFlag == PR_TRUE)	continue;					}					if (hostStr.Length() > 0)					{						char		*absHost = nsnull;						absURI->GetHost(&absHost);						if (absHost)						{							PRBool	hostsMatchFlag = hostStr.EqualsIgnoreCase(absHost);							nsCRT::free(absHost);							if (hostsMatchFlag == PR_TRUE)	continue;						}					}				}			}			// if this result is to be filtered out, notice it now			if (isSearchResultFiltered(hrefStr) == PR_TRUE)				continue;			nsAutoString	site(hrefStr);#ifdef	DEBUG_SEARCH_OUTPUT			char *hrefCStr = ToNewCString(hrefStr);			if (hrefCStr)			{				printf("HREF: '%s'\n", hrefCStr);				nsCRT::free(hrefCStr);				hrefCStr = nsnull;			}#endif			nsCOMPtr<nsIRDFResource>	res;// #define	OLDWAY#ifdef	OLDWAY			rv = gRDFService->GetResource(nsCAutoString(hrefStr), getter_AddRefs(res));#else					// save HREF attribute as URL			if (NS_SUCCEEDED(rv = gRDFService->GetAnonymousResource(getter_AddRefs(res))))			{				const PRUnichar	*hrefUni = hrefStr.get();				if (hrefUni)				{					nsCOMPtr<nsIRDFLiteral>	hrefLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(hrefUni, getter_AddRefs(hrefLiteral))))					{						mInner->Assert(res, kNC_URL, hrefLiteral, PR_TRUE);					}				}			}	#endif			if (NS_FAILED(rv))	continue;						// set HTML response chunk			const PRUnichar	*htmlResponseUni = resultItem.get();			if (htmlResponseUni)			{				nsCOMPtr<nsIRDFLiteral>	htmlResponseLiteral;				if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(htmlResponseUni, getter_AddRefs(htmlResponseLiteral))))				{					if (htmlResponseLiteral)					{						mInner->Assert(res, kNC_HTML, htmlResponseLiteral, PR_TRUE);					}				}			}						// set banner (if we have one)			if (bannerLiteral)			{				mInner->Assert(res, kNC_Banner, bannerLiteral, PR_TRUE);			}			// look for Site (if it isn't already set)			nsCOMPtr<nsIRDFNode>		oldSiteRes = nsnull;			mInner->GetTarget(res, kNC_Site, PR_TRUE, getter_AddRefs(oldSiteRes));			if (!oldSiteRes)			{				PRInt32	protocolOffset = site.FindCharInSet(":", 0);				if (protocolOffset >= 0)				{					site.Cut(0, protocolOffset+1);					while (site[0] == PRUnichar('/'))					{						site.Cut(0, 1);					}					PRInt32	slashOffset = site.FindCharInSet("/", 0);					if (slashOffset >= 0)					{						site.Truncate(slashOffset);					}					if (site.Length() > 0)					{						const PRUnichar	*siteUni = site.get();						if (siteUni)						{							nsCOMPtr<nsIRDFLiteral>	siteLiteral;							if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(siteUni, getter_AddRefs(siteLiteral))))							{								if (siteLiteral)								{									mInner->Assert(res, kNC_Site, siteLiteral, PR_TRUE);								}							}						}					}				}			}			// look for name			nsAutoString	nameStr;			if ((nameStartStr.Length() > 0) && (nameEndStr.Length() > 0))			{				PRInt32		nameStart;				if ((nameStart = resultItem.Find(nameStartStr, PR_TRUE)) >= 0)				{					nameStart += nameStartStr.Length();					PRInt32	nameEnd = resultItem.Find(nameEndStr, PR_TRUE, nameStart);					if (nameEnd > nameStart)					{						resultItem.Mid(nameStr, nameStart, nameEnd - nameStart);					}				}			}			if (nameStr.Length() < 1)			{				PRInt32	anchorEnd = resultItem.FindCharInSet(">", quoteEndOffset);				if (anchorEnd < quoteEndOffset)				{#ifdef	DEBUG_SEARCH_OUTPUT					printf("\n\nSearch: Unable to find ending > when computing name.\n\n");#endif					continue;				}				PRInt32	anchorStop = resultItem.Find("</A>", PR_TRUE, quoteEndOffset);				if (anchorStop < anchorEnd)				{#ifdef	DEBUG_SEARCH_OUTPUT					printf("\n\nSearch: Unable to find </A> tag to compute name.\n\n");#endif					continue;				}				resultItem.Mid(nameStr, anchorEnd + 1, anchorStop - anchorEnd - 1);			}			ConvertEntities(nameStr);			// look for Name (if it isn't already set)			nsCOMPtr<nsIRDFNode>		oldNameRes = nsnull;#ifdef	OLDWAY			mInner->GetTarget(res, kNC_Name, PR_TRUE, getter_AddRefs(oldNameRes));#endif			if (!oldNameRes)			{				if (nameStr.Length() > 0)				{					const PRUnichar	*nameUni = nameStr.get();					if (nameUni)					{						nsCOMPtr<nsIRDFLiteral>	nameLiteral;						if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(nameUni, getter_AddRefs(nameLiteral))))						{							if (nameLiteral)							{								mInner->Assert(res, kNC_Name, nameLiteral, PR_TRUE);							}						}					}				}			}			// look for date			if (dateStartStr.Length() > 0)			{				nsAutoString	dateItem;				PRInt32		dateStart;				if ((dateStart = resultItem.Find(dateStartStr, PR_TRUE)) >= 0)				{					dateStart += dateStartStr.Length();					PRInt32	dateEnd = resultItem.Find(dateEndStr, PR_TRUE, dateStart);					if (dateEnd > dateStart)					{						resultItem.Mid(dateItem, dateStart, dateEnd - dateStart);					}				}								// strip out any html tags				PRInt32		ltOffset, gtOffset;				while ((ltOffset = dateItem.FindChar(PRUnichar('<'))) >= 0)				{					if ((gtOffset = dateItem.FindChar(PRUnichar('>'), PR_FALSE, ltOffset)) <= ltOffset)						break;					dateItem.Cut(ltOffset, gtOffset - ltOffset + 1);				}				// strip out whitespace and any CR/LFs				dateItem.Trim("\n\r\t ");				if (dateItem.Length() > 0)				{					const PRUnichar		*dateUni = dateItem.get();					nsCOMPtr<nsIRDFLiteral>	dateLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(dateUni, getter_AddRefs(dateLiteral))))					{						if (dateLiteral)						{							mInner->Assert(res, kNC_Date, dateLiteral, PR_TRUE);							hasDateFlag = PR_TRUE;						}					}				}			}			// look for price			if (priceStartStr.Length() > 0)			{				nsAutoString	priceItem;				PRInt32		priceStart;				if ((priceStart = resultItem.Find(priceStartStr, PR_TRUE)) >= 0)				{					priceStart += priceStartStr.Length();					PRInt32	priceEnd = resultItem.Find(priceEndStr, PR_TRUE, priceStart);					if (priceEnd > priceStart)					{						resultItem.Mid(priceItem, priceStart, priceEnd - priceStart);						ConvertEntities(priceItem);					}				}				if (priceItem.Length() > 0)				{					const PRUnichar		*priceUni = priceItem.get();					nsCOMPtr<nsIRDFLiteral>	priceLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(priceUni, getter_AddRefs(priceLiteral))))					{						if (priceLiteral)						{							mInner->Assert(res, kNC_Price, priceLiteral, PR_TRUE);							hasPriceFlag = PR_TRUE;						}					}					PRInt32	priceCharStartOffset = priceItem.FindCharInSet("1234567890");					if (priceCharStartOffset >= 0)					{						priceItem.Cut(0, priceCharStartOffset);						PRInt32	priceErr;						float	val = priceItem.ToFloat(&priceErr);						if (priceItem.FindChar(PRUnichar('.')) >= 0)	val *= 100;						nsCOMPtr<nsIRDFInt>	priceSortLiteral;						if (NS_SUCCEEDED(rv = gRDFService->GetIntLiteral((PRInt32)val, getter_AddRefs(priceSortLiteral))))						{							if (priceSortLiteral)							{								mInner->Assert(res, kNC_PriceSort, priceSortLiteral, PR_TRUE);							}						}					}									}			}			// look for availability			if (availStartStr.Length() > 0)			{				nsAutoString	availItem;				PRInt32		availStart;				if ((availStart = resultItem.Find(availStartStr, PR_TRUE)) >= 0)				{					availStart += availStartStr.Length();					PRInt32	availEnd = resultItem.Find(availEndStr, PR_TRUE, availStart);					if (availEnd > availStart)					{						resultItem.Mid(availItem, availStart, availEnd - availStart);						ConvertEntities(availItem);					}				}				if (availItem.Length() > 0)				{					const PRUnichar		*availUni = availItem.get();					nsCOMPtr<nsIRDFLiteral>	availLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(availUni, getter_AddRefs(availLiteral))))					{						if (availLiteral)						{							mInner->Assert(res, kNC_Availability, availLiteral, PR_TRUE);							hasAvailabilityFlag = PR_TRUE;						}					}				}			}			// look for relevance			nsAutoString	relItem;			PRInt32		relStart;			if ((relStart = resultItem.Find(relevanceStartStr, PR_TRUE)) >= 0)			{				relStart += relevanceStartStr.Length();				PRInt32	relEnd = resultItem.Find(relevanceEndStr, PR_TRUE);				if (relEnd > relStart)				{					resultItem.Mid(relItem, relStart, relEnd - relStart);				}			}			// look for Relevance (if it isn't already set)			nsCOMPtr<nsIRDFNode>		oldRelRes = nsnull;#ifdef	OLDWAY			mInner->GetTarget(res, kNC_Relevance, PR_TRUE, getter_AddRefs(oldRelRes));#endif			if (!oldRelRes)			{				if (relItem.Length() > 0)				{					// save real relevance					const PRUnichar	*relUni = relItem.get();					if (relUni)					{						nsAutoString	relStr(relUni);						// take out any characters that aren't numeric or "%"						PRInt32	len = relStr.Length();						for (PRInt32 x=len-1; x>=0; x--)						{							PRUnichar	ch;							ch = relStr.CharAt(x);							if ((ch != PRUnichar('%')) &&								((ch < PRUnichar('0')) || (ch > PRUnichar('9'))))							{								relStr.Cut(x, 1);							}						}						// make sure it ends with a "%"						len = relStr.Length();						if (len > 0)						{							PRUnichar	ch;							ch = relStr.CharAt(len - 1);							if (ch != PRUnichar('%'))							{								relStr += PRUnichar('%');							}							relItem = relStr;							hasRelevanceFlag = PR_TRUE;						}						else						{							relItem.Truncate();						}					}				}				if (relItem.Length() < 1)				{					relItem.AssignWithConversion("-");				}				const PRUnichar *relItemUni = relItem.get();				nsCOMPtr<nsIRDFLiteral>	relLiteral;				if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(relItemUni, getter_AddRefs(relLiteral))))				{					if (relLiteral)					{						mInner->Assert(res, kNC_Relevance, relLiteral, PR_TRUE);					}				}				if ((relItem.Length() > 0) && (!relItem.EqualsWithConversion("-")))				{					// If its a percentage, remove "%"					if (relItem[relItem.Length()-1] == PRUnichar('%'))					{						relItem.Cut(relItem.Length()-1, 1);					}					// left-pad with "0"s and set special sorting value					nsAutoString	zero;					zero.AssignWithConversion("000");					if (relItem.Length() < 3)					{						relItem.Insert(zero.get(), 0, zero.Length() - relItem.Length()); 					}				}				else				{					relItem.AssignWithConversion("000");				}				const PRUnichar	*relSortUni = relItem.get();				if (relSortUni)				{					nsCOMPtr<nsIRDFLiteral>	relSortLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(relSortUni, getter_AddRefs(relSortLiteral))))					{						if (relSortLiteral)						{							mInner->Assert(res, kNC_RelevanceSort, relSortLiteral, PR_TRUE);						}					}				}			}			// set reference to engine this came from (if it isn't already set)			nsCOMPtr<nsIRDFNode>		oldEngineRes = nsnull;#ifdef	OLDWAY			mInner->GetTarget(res, kNC_Engine, PR_TRUE, getter_AddRefs(oldEngineRes));#endif			if (!oldEngineRes)			{				if (engineStr.Length() > 0)				{					const PRUnichar		*engineUni = engineStr.get();					nsCOMPtr<nsIRDFLiteral>	engineLiteral;					if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(engineUni, getter_AddRefs(engineLiteral))))					{						if (engineLiteral)						{							mInner->Assert(res, kNC_Engine, engineLiteral, PR_TRUE);						}					}				}			}			// copy the engine's icon reference (if it has one) onto the result node			nsCOMPtr<nsIRDFNode>		engineIconNode = nsnull;			mInner->GetTarget(mEngine, kNC_Icon, PR_TRUE, getter_AddRefs(engineIconNode));			// if no branding icon, use some default icons			nsAutoString	iconChromeDefault;			if (browserResultTypeStr.EqualsIgnoreCase("category"))				iconChromeDefault.AssignWithConversion("chrome://communicator/skin/search/category.gif");			else if ((browserResultTypeStr.EqualsIgnoreCase("result")) && (!engineIconNode))				iconChromeDefault.AssignWithConversion("chrome://communicator/skin/search/result.gif");			if (iconChromeDefault.Length() > 0)			{				const PRUnichar		*iconUni = iconChromeDefault.get();				nsCOMPtr<nsIRDFLiteral>	iconLiteral;				if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(iconUni, getter_AddRefs(iconLiteral))))				{					if (iconLiteral)					{						mInner->Assert(res, kNC_Icon, iconLiteral, PR_TRUE);					}				}			}			else if (engineIconNode)			{				rv = mInner->Assert(res, kNC_Icon, engineIconNode, PR_TRUE);			}			// set result page rank			nsCOMPtr<nsIRDFInt>	pageRankLiteral;			if (NS_SUCCEEDED(rv = gRDFService->GetIntLiteral(pageRank++, getter_AddRefs(pageRankLiteral))))			{				rv = mInner->Assert(res, kNC_PageRank, pageRankLiteral, PR_TRUE);			}			// set the result type			if (browserResultTypeStr.Length() > 0)			{				const PRUnichar		*resultTypeUni = browserResultTypeStr.get();				nsCOMPtr<nsIRDFLiteral>	resultTypeLiteral;				if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(resultTypeUni, getter_AddRefs(resultTypeLiteral))))				{					if (resultTypeLiteral)					{						mInner->Assert(res, kNC_SearchType, resultTypeLiteral, PR_TRUE);					}				}			}			// set the node type			rv = mInner->Assert(res, kRDF_type, kNC_SearchResult, PR_TRUE);			// Note: always add in parent-child relationship last!  (if it isn't already set)#ifdef	OLDWAY			PRBool		parentHasChildFlag = PR_FALSE;			if (mParent)			{				mInner->HasAssertion(mParent, kNC_Child, res, PR_TRUE, &parentHasChildFlag);			}			if (parentHasChildFlag == PR_FALSE)#endif			{				if (mParent)				{					rv = mInner->Assert(mParent, kNC_Child, res, PR_TRUE);				}			}			// Persist this under kNC_LastSearchRoot			if (mInner)			{				rv = mInner->Assert(kNC_LastSearchRoot, kNC_Child, res, PR_TRUE);			}			++numResults;		}	}	// set hints so that the appropriate columns can be displayed	if (mParent)	{		if (hasPriceFlag == PR_TRUE)		SetHint(mParent, kNC_Price);		if (hasAvailabilityFlag == PR_TRUE)	SetHint(mParent, kNC_Availability);		if (hasRelevanceFlag == PR_TRUE)	SetHint(mParent, kNC_Relevance);		if (hasDateFlag == PR_TRUE)		SetHint(mParent, kNC_Date);	}	return(NS_OK);}