PRInt32 priceTagStartOffset; while ((priceTagStartOffset = priceItem.FindCharInSet("<", 0)) >= 0) { PRInt32	priceTagEndOffset = priceItem.FindCharInSet(">", priceTagStartOffset); if (priceTagEndOffset <= priceTagStartOffset)	break; priceItem.Cut(priceTagStartOffset, priceTagEndOffset - priceTagStartOffset + 1); }  PRInt32	priceEOLOffset; while ((priceEOLOffset = priceItem.FindCharInSet("\n\r", 0)) >= 0) { priceItem.Cut(priceEOLOffset, 1); }
ConvertEntities(priceItem);
InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *mEngine,	const nsString &htmlPage, PRBool useAllHREFsFlag, PRUint32 &numResults){	nsAutoString	htmlResults(htmlPage);	nsAutoString	data, engineStr;	nsAutoString	resultListStartStr, resultListEndStr;	nsAutoString	resultItemStartStr, resultItemEndStr;	nsAutoString	relevanceStartStr, relevanceEndStr;	nsAutoString	bannerStartStr, bannerEndStr, skiplocalStr;	nsAutoString	priceStartStr, priceEndStr, availStartStr, availEndStr;	PRBool		skipLocalFlag = PR_FALSE;	nsresult	rv;	numResults = 0;	if (useAllHREFsFlag == PR_TRUE)	{		skipLocalFlag = PR_TRUE;	}	else	{		// get data out of graph		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);		PRUnichar	*dataUni = nsnull;		if (NS_FAILED(rv = dataLiteral->GetValue(&dataUni)))			return(rv);		if (!dataUni)	return(NS_ERROR_NULL_POINTER);		data = dataUni;		if (data.Length() < 1)			return(rv);		GetData(data, "interpret", "resultListStart", resultListStartStr);		GetData(data, "interpret", "resultListEnd", resultListEndStr);		GetData(data, "interpret", "resultItemStart", resultItemStartStr);		GetData(data, "interpret", "resultItemEnd", resultItemEndStr);		GetData(data, "interpret", "relevanceStart", relevanceStartStr);		GetData(data, "interpret", "relevanceEnd", relevanceEndStr);		GetData(data, "interpret", "bannerStart", bannerStartStr);		GetData(data, "interpret", "bannerEnd", bannerEndStr);		GetData(data, "interpret", "skiplocal", skiplocalStr);		if (skiplocalStr.EqualsIgnoreCase("true"))		{			skipLocalFlag = PR_TRUE;		}		GetData(data, "search", "name", engineStr);		GetData(data, "interpret", "priceStart", priceStartStr);		GetData(data, "interpret", "priceEnd", priceEndStr);		GetData(data, "interpret", "availStart", availStartStr);		GetData(data, "interpret", "availEnd", availEndStr);#ifdef	DEBUG_SEARCH_OUTPUT		char *cStr;		cStr = resultListStartStr.ToNewCString();		if (cStr)		{			printf("resultListStart: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}		cStr = resultListEndStr.ToNewCString();		if (cStr)		{			printf("resultListEnd: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}		cStr = resultItemStartStr.ToNewCString();		if (cStr)		{			printf("resultItemStart: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}		cStr = resultItemEndStr.ToNewCString();		if (cStr)		{			printf("resultItemEnd: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}		cStr = relevanceStartStr.ToNewCString();		if (cStr)		{			printf("relevanceStart: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}		cStr = relevanceEndStr.ToNewCString();		if (cStr)		{			printf("relevanceEnd: '%s'\n", cStr);			nsCRT::free(cStr);			cStr = nsnull;		}#endif	}	// pre-compute host (we might discard URLs that match this)	nsAutoString	hostStr;	char		*hostName = nsnull;	aURL->GetHost(&hostName);	if (hostName)	{		hostStr = 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 = serverPath;		nsCRT::free(serverPath);		serverPath = nsnull;		PRInt32 serverOptionsOffset = serverPathStr.FindChar(PRUnichar('?'));		if (serverOptionsOffset >= 0)	serverPathStr.Truncate(serverOptionsOffset);	}	// look for banner once in entire document	nsCOMPtr<nsIRDFLiteral>	bannerLiteral;	if ((bannerStartStr.Length() > 0) && (bannerEndStr.Length() > 0))	{		PRInt32	bannerStart = htmlResults.Find(bannerStartStr, PR_TRUE);		if (bannerStart >= 0)		{			nsAutoString	htmlCopy(htmlResults);			htmlCopy.Cut(0, bannerStart + bannerStartStr.Length());						PRInt32	bannerEnd = htmlCopy.Find(bannerEndStr, PR_TRUE);			if (bannerEnd > 0)			{				htmlCopy.Truncate(bannerEnd);				if (htmlCopy.Length() > 0)				{					const PRUnichar	*bannerUni = htmlCopy.GetUnicode();					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());		}	}	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 = "HREF=";		trimItemStart = PR_FALSE;	}	// if resultItemEndStr is not specified, try making it the same as resultItemStartStr	if (resultItemEndStr.Length() < 1)	{		resultItemEndStr = resultItemStartStr;		trimItemEnd = PR_FALSE;	}	PRBool	hasPriceFlag = PR_FALSE, hasAvailabilityFlag = PR_FALSE, hasRelevanceFlag = PR_FALSE;	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;		}		nsAutoString	resultItem;		htmlResults.Left(resultItem, resultItemEnd);		if (resultItem.Length() < 1)	break;		if (trimItemEnd == PR_TRUE)		{			htmlResults.Cut(0, resultItemEnd + resultItemEndStr.Length());		}		else		{			htmlResults.Cut(0, resultItemEnd);		}#ifdef	DEBUG_SEARCH_OUTPUT		char	*results = resultItem.ToNewCString();		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);		if (hrefStr.Length() < 1)	continue;		char		*absURIStr = nsnull;		if (NS_SUCCEEDED(rv = NS_MakeAbsoluteURI(nsCAutoString(hrefStr),			aURL, &absURIStr)) && (absURIStr))		{			nsCOMPtr<nsIURI>	absURI;			rv = NS_NewURI(getter_AddRefs(absURI), absURIStr);			nsCRT::free(absURIStr);			absURIStr = nsnull;			if (absURI)			{				char	*absPath = nsnull;				absURI->GetPath(&absPath);				if (absPath)				{					nsAutoString	absPathStr(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) && (skipLocalFlag == PR_TRUE))				{					char		*absHost = nsnull;					absURI->GetHost(&absHost);					if (absHost)					{						PRBool	hostsMatchFlag = hostStr.EqualsIgnoreCase(absHost);						nsCRT::free(absHost);						if (hostsMatchFlag == PR_TRUE)	continue;					}				}			}		}		nsAutoString	site(hrefStr);#ifdef	DEBUG_SEARCH_OUTPUT		printf("HREF: '%s'\n", href);#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.GetUnicode();			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.GetUnicode();		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.GetUnicode();					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		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.FindChar(PRUnichar('<'), PR_TRUE, quoteEndOffset);		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;		}				nsAutoString	nameStr;		resultItem.Mid(nameStr, anchorEnd + 1, anchorStop - anchorEnd - 1);		// munge any "&quot;" in name		PRInt32	quotOffset;		while ((quotOffset = nameStr.Find("&quot;", PR_TRUE)) >= 0)		{			nameStr.Cut(quotOffset, strlen("&quot;"));			nameStr.Insert(PRUnichar('\"'), quotOffset);		}				// munge any "&amp;" in name		PRInt32	ampOffset;		while ((ampOffset = nameStr.Find("&amp;", PR_TRUE)) >= 0)		{			nameStr.Cut(ampOffset, strlen("&amp;"));			nameStr.Insert(PRUnichar('&'), ampOffset);		}				// munge any "&nbsp;" in name		PRInt32	nbspOffset;		while ((nbspOffset = nameStr.Find("&nbsp;", PR_TRUE)) >= 0)		{			nameStr.Cut(nbspOffset, strlen("&nbsp;"));			nameStr.Insert(PRUnichar(' '), nbspOffset);		}		// munge any "&lt;" in name		PRInt32	ltOffset;		while ((ltOffset = nameStr.Find("&lt;", PR_TRUE)) >= 0)		{			nameStr.Cut(ltOffset, strlen("&lt;"));			nameStr.Insert(PRUnichar('<'), ltOffset);		}		// munge any "&gt;" in name		PRInt32	gtOffset;		while ((gtOffset = nameStr.Find("&gt;", PR_TRUE)) >= 0)		{			nameStr.Cut(gtOffset, strlen("&gt;"));			nameStr.Insert(PRUnichar('>'), gtOffset);		}				// munge out anything inside of HTML "<" / ">" tags		PRInt32 tagStartOffset;		while ((tagStartOffset = nameStr.FindCharInSet("<", 0)) >= 0)		{			PRInt32	tagEndOffset = nameStr.FindCharInSet(">", tagStartOffset);			if (tagEndOffset <= tagStartOffset)	break;			nameStr.Cut(tagStartOffset, tagEndOffset - tagStartOffset + 1);		}		// cut out any CRs or LFs		PRInt32	eolOffset;		while ((eolOffset = nameStr.FindCharInSet("\n\r", 0)) >= 0)		{			nameStr.Cut(eolOffset, 1);		}		// and trim name		nameStr = nameStr.Trim(" \t");		// 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.GetUnicode();				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 price		nsAutoString	priceItem;		PRInt32		priceStart;		if ((priceStart = resultItem.Find(priceStartStr, PR_TRUE)) >= 0)		{			PRInt32	priceEnd = resultItem.Find(priceEndStr, PR_TRUE, priceStart + priceStartStr.Length());			if (priceEnd > priceStart)			{				resultItem.Mid(priceItem, priceStart + priceStartStr.Length(),					priceEnd - priceStart - priceStartStr.Length());				// munge out anything inside of HTML "<" / ">" tags				PRInt32 priceTagStartOffset;				while ((priceTagStartOffset = priceItem.FindCharInSet("<", 0)) >= 0)				{					PRInt32	priceTagEndOffset = priceItem.FindCharInSet(">", priceTagStartOffset);					if (priceTagEndOffset <= priceTagStartOffset)	break;					priceItem.Cut(priceTagStartOffset, priceTagEndOffset - priceTagStartOffset + 1);				}				// cut out any CRs or LFs				PRInt32	priceEOLOffset;				while ((priceEOLOffset = priceItem.FindCharInSet("\n\r", 0)) >= 0)				{					priceItem.Cut(priceEOLOffset, 1);				}			}		}		if (priceItem.Length() > 0)		{			const PRUnichar		*priceUni = priceItem.GetUnicode();			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		nsAutoString	availItem;		PRInt32		availStart;		if ((availStart = resultItem.Find(availStartStr, PR_TRUE)) >= 0)		{			PRInt32	availEnd = resultItem.Find(availEndStr, PR_TRUE, availStart + availStartStr.Length());			if (availEnd > availStart)			{				resultItem.Mid(availItem, availStart + availStartStr.Length(),					availEnd - availStart - availStartStr.Length());				// munge out anything inside of HTML "<" / ">" tags				PRInt32 availTagStartOffset;				while ((availTagStartOffset = availItem.FindCharInSet("<", 0)) >= 0)				{					PRInt32	availTagEndOffset = availItem.FindCharInSet(">", availTagStartOffset);					if (availTagEndOffset <= availTagStartOffset)	break;					availItem.Cut(availTagStartOffset, availTagEndOffset - availTagStartOffset + 1);				}				// cut out any CRs or LFs				PRInt32	availEOLOffset;				while ((availEOLOffset = availItem.FindCharInSet("\n\r", 0)) >= 0)				{					availItem.Cut(availEOLOffset, 1);				}			}		}		if (availItem.Length() > 0)		{			const PRUnichar		*availUni = availItem.GetUnicode();			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)		{			PRInt32	relEnd = resultItem.Find(relevanceEndStr, PR_TRUE);			if (relEnd > relStart)			{				resultItem.Mid(relItem, relStart + relevanceStartStr.Length(),					relEnd - relStart - relevanceStartStr.Length());			}		}		// 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.GetUnicode();				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 = "-";			}			const PRUnichar *relItemUni = relItem.GetUnicode();			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.Equals("-")))			{				// 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("000");				if (relItem.Length() < 3)				{					relItem.Insert(zero, 0, zero.Length() - relItem.Length()); 				}			}			else			{				relItem = "000";			}			const PRUnichar	*relSortUni = relItem.GetUnicode();			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) && (data.Length() > 0))		{			if (engineStr.Length() > 0)			{				const PRUnichar		*engineUni = engineStr.GetUnicode();				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 (engineIconNode)		{			rv = mInner->Assert(res, kNC_Icon, engineIconNode, PR_TRUE);		}#ifdef	OLDWAY		// Note: always add in parent-child relationship last!  (if it isn't already set)		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 (hasPriceFlag == PR_TRUE)		SetHint(mParent, kNC_Price);	if (hasAvailabilityFlag == PR_TRUE)	SetHint(mParent, kNC_Availability);	if (hasRelevanceFlag == PR_TRUE)	SetHint(mParent, kNC_Relevance);	return(NS_OK);}