PRInt32	bannerStart = nsString_Find(bannerStartStr, htmlResults, PR_TRUE);
PRInt32	bannerStart = htmlResults.Find(bannerStartStr, PR_TRUE);
InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,				nsIRDFResource *mEngine, const PRUnichar *htmlPage, PRInt32 htmlPageSize){	// 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)	nsCAutoString hostName;	aURL->GetAsciiHost(hostName);	// pre-compute server path (we might discard URLs that match this)	nsAutoString	serverPathStr;	nsCAutoString serverPath;	aURL->GetPath(serverPath);	if (!serverPath.IsEmpty())	{        serverPathStr = NS_ConvertUTF8toUCS2(serverPath);        serverPath.Truncate();		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;	}#ifdef	DEBUG	PRTime		now;#ifdef	XP_MAC	Microseconds((UnsignedWide *)&now);#else	now = PR_Now();#endif       printf("\nStart processing search results:   %u bytes \n", htmlPageSize); #endif	// 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.Assign(NS_LITERAL_STRING("result"));		// default to "result"		// use a CBufDescriptor so that "htmlPage" data isn't copied		CBufDescriptor	htmlPageDecriptor( htmlPage, PR_TRUE, htmlPageSize);		nsAutoString		htmlResults(htmlPageDecriptor);		PRUint32        startIndex = 0L, stopIndex = htmlPageSize;		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.IsEmpty())			{				browserResultTypeStr.Assign(NS_LITERAL_STRING("result"));	// default to "result"			}		}		// look for banner		nsCOMPtr<nsIRDFLiteral>	bannerLiteral;		if ((!bannerStartStr.IsEmpty()) && (!bannerEndStr.IsEmpty()))		{			PRInt32	bannerStart = nsString_Find(bannerStartStr, htmlResults, PR_TRUE);			if (bannerStart >= 0)			{				startIndex = bannerStart;				PRInt32	bannerEnd = nsString_Find(bannerEndStr,htmlResults, PR_TRUE, bannerStart + bannerStartStr.Length());				if (bannerEnd > bannerStart)				{					stopIndex = bannerEnd - 1;					nsAutoString	htmlBanner;					htmlResults.Mid(htmlBanner, bannerStart, bannerEnd - bannerStart - 1);					if (!htmlBanner.IsEmpty())					{						const PRUnichar	*bannerUni = htmlBanner.get();						if (bannerUni)						{							gRDFService->GetLiteral(bannerUni, getter_AddRefs(bannerLiteral));						}					}				}			}		}		if (!resultListStartStr.IsEmpty())		{			PRInt32	resultListStart = nsString_Find(resultListStartStr, htmlResults, PR_TRUE);			if (resultListStart >= 0)			{        startIndex = resultListStart + resultListStartStr.Length();			}			else if (useAllHREFsFlag == PR_FALSE)			{				// if we have multiple <INTERPRET> sections but can't find the startIndex				// of a result list block, just continue on with the the next block				continue;			}		}		if (!resultListEndStr.IsEmpty())		{			// rjc note: use RFind to find the LAST			// occurrence of resultListEndStr		    nsAString::const_iterator originalStart, start, end;		    htmlResults.BeginReading(start);		    htmlResults.EndReading(end);		    originalStart = start;		    		    if (RFindInReadable(resultListEndStr, start, end))			stopIndex = Distance(originalStart, start);		}		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.IsEmpty())		{			resultItemStartStr.Assign(NS_LITERAL_STRING("HREF="));			trimItemStart = PR_FALSE;		}		// if resultItemEndStr is not specified, try making it the same as resultItemStartStr		if (resultItemEndStr.IsEmpty())		{			resultItemEndStr = resultItemStartStr;			trimItemEnd = PR_TRUE;		}		while(startIndex < stopIndex)		{			PRInt32	resultItemStart;			resultItemStart = nsString_Find(resultItemStartStr, htmlResults, PR_TRUE, startIndex);			if (resultItemStart < 0)	break;			PRInt32	resultItemEnd;			if (trimItemStart == PR_TRUE)			{				resultItemStart += resultItemStartStr.Length();				resultItemEnd = nsString_Find(resultItemEndStr, htmlResults, PR_TRUE, resultItemStart);			}			else			{				resultItemEnd = nsString_Find(resultItemEndStr, htmlResults, PR_TRUE, resultItemStart + resultItemStartStr.Length());			}			if (resultItemEnd < 0)			{				resultItemEnd = stopIndex;			}			else if ((trimItemEnd == PR_FALSE) && (resultItemEnd >= 0))			{				resultItemEnd += resultItemEndStr.Length();			}			// forced to use an nsAutoString (which copies)			// as CBufDescriptor doesn't guarantee null terminator			nsAutoString resultItem(&htmlPage[resultItemStart],				resultItemEnd - resultItemStart - 1);			if (resultItem.IsEmpty())	break;			// advance startIndex here so that, from this point onward, "continue" can be used			startIndex = 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 + strlen("HREF=");				quoteEndOffset = resultItem.FindChar('>', quoteStartOffset);				if (quoteEndOffset < quoteStartOffset)	continue;			}			else			{				if (resultItem[quoteStartOffset] == PRUnichar('>'))				{					// handle case where HREF isn't quoted					quoteEndOffset = quoteStartOffset;					quoteStartOffset = hrefOffset + 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			hrefStr.StripChars("\n\r");			if (hrefStr.IsEmpty())	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))				{					nsCAutoString absPath;					absURI->GetPath(absPath);					if (!absPath.IsEmpty())					{                        NS_ConvertUTF8toUCS2 absPathStr(absPath);						PRInt32 pathOptionsOffset = absPathStr.FindChar(PRUnichar('?'));						if (pathOptionsOffset >= 0)							absPathStr.Truncate(pathOptionsOffset);						PRBool	pathsMatchFlag = serverPathStr.Equals(absPathStr, nsCaseInsensitiveStringComparator());						if (pathsMatchFlag == PR_TRUE)	continue;					}					if (!hostName.IsEmpty())					{						nsCAutoString absHost;						absURI->GetAsciiHost(absHost);						if (!absHost.IsEmpty())						{							PRBool	hostsMatchFlag = !nsCRT::strcasecmp(hostName.get(), absHost.get());							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.FindChar(':', 0);				if (protocolOffset >= 0)				{					site.Cut(0, protocolOffset+1);					while (site[0] == PRUnichar('/'))					{						site.Cut(0, 1);					}					PRInt32	slashOffset = site.FindChar('/', 0);					if (slashOffset >= 0)					{						site.Truncate(slashOffset);					}					if (!site.IsEmpty())					{						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.IsEmpty()) && (!nameEndStr.IsEmpty()))			{				PRInt32		nameStart;				if ((nameStart = nsString_Find(nameStartStr, resultItem, PR_TRUE)) >= 0)				{					nameStart += nameStartStr.Length();					PRInt32	nameEnd = nsString_Find(nameEndStr, resultItem, PR_TRUE, nameStart);					if (nameEnd > nameStart)					{						resultItem.Mid(nameStr, nameStart, nameEnd - nameStart);					}				}			}			if (nameStr.IsEmpty())			{				PRInt32	anchorEnd = resultItem.FindChar('>', 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.IsEmpty())				{					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.IsEmpty())			{				nsAutoString	dateItem;				PRInt32		dateStart;				if ((dateStart = nsString_Find(dateStartStr, resultItem, PR_TRUE)) >= 0)				{					dateStart += dateStartStr.Length();					PRInt32	dateEnd = nsString_Find(dateEndStr, resultItem, 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('>'), ltOffset)) <= ltOffset)						break;					dateItem.Cut(ltOffset, gtOffset - ltOffset + 1);				}				// strip out whitespace and any CR/LFs				dateItem.Trim("\n\r\t ");				if (!dateItem.IsEmpty())				{					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.IsEmpty())			{				nsAutoString	priceItem;				PRInt32		priceStart;				if ((priceStart = nsString_Find(priceStartStr, resultItem, PR_TRUE)) >= 0)				{					priceStart += priceStartStr.Length();					PRInt32	priceEnd = nsString_Find(priceEndStr, resultItem, PR_TRUE, priceStart);					if (priceEnd > priceStart)					{						resultItem.Mid(priceItem, priceStart, priceEnd - priceStart);						ConvertEntities(priceItem);					}				}				if (!priceItem.IsEmpty())				{					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 we looked for price)				if (!availStartStr.IsEmpty())				{					nsAutoString	availItem;					PRInt32		availStart;					if ((availStart = nsString_Find(availStartStr, resultItem, PR_TRUE)) >= 0)					{						availStart += availStartStr.Length();						PRInt32	availEnd = nsString_Find(availEndStr, resultItem, PR_TRUE, availStart);						if (availEnd > availStart)						{							resultItem.Mid(availItem, availStart, availEnd - availStart);							ConvertEntities(availItem);						}					}					if (!availItem.IsEmpty())					{						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 = nsString_Find(relevanceStartStr, resultItem, PR_TRUE)) >= 0)			{				relStart += relevanceStartStr.Length();				PRInt32	relEnd = nsString_Find(relevanceEndStr, resultItem, 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.IsEmpty())				{					// 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.IsEmpty())				{					relItem.Assign(NS_LITERAL_STRING("-"));				}				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.IsEmpty()) && (!relItem.Equals(NS_LITERAL_STRING("-"))))				{					// 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.Assign(NS_LITERAL_STRING("000"));					if (relItem.Length() < 3)					{						relItem.Insert(zero.get(), 0, zero.Length() - relItem.Length()); 					}				}				else				{					relItem.Assign(NS_LITERAL_STRING("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.IsEmpty())				{					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.Assign(NS_LITERAL_STRING("chrome://communicator/skin/search/category.gif"));			else if ((browserResultTypeStr.EqualsIgnoreCase("result")) && (!engineIconNode))				iconChromeDefault.Assign(NS_LITERAL_STRING("chrome://communicator/skin/search/result.gif"));			if (!iconChromeDefault.IsEmpty())			{				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.IsEmpty())			{				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;			// place a cap on the # of results we can process			if (numResults >= MAX_SEARCH_RESULTS_ALLOWED)				break;		}	}	// 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);	}#ifdef	DEBUG	PRTime		now2;#ifdef	XP_MAC	Microseconds((UnsignedWide *)&now2);#else	now2 = PR_Now();#endif	PRUint64	loadTime64;	LL_SUB(loadTime64, now2, now);	PRUint32	loadTime32;	LL_L2UI(loadTime32, loadTime64);	printf("Finished processing search results  (%u microseconds)\n", loadTime32);#endif	return(NS_OK);}