How to: Enable HTML Rendering for the Federated Results Web Part
Last modified: May 01, 2010
Applies to: SharePoint Server 2010
By default, the XSLT transformation (XSLT) of the Federated Results Web Part removes HTML from the display for security reasons. However, you might want to display a field that contains HTML in a Federated Results Web Part that displays results from a trusted location source. You can do this by making the following changes to the XSL property of a federated location or the Web Part:
Ensure that the HTML is not removed from the display.
Disable output caching.
Disable truncating (optional).
This topic describes these changes.
If you update the federated location's XSL property, you must ensure that the Web Part is configured to use the location's display information.
To configure the Federated Results Web Part to use the location's display information
In your browser, navigate to the results page URL. For example, http:// ServerName/results.aspx.
Click the Site Actions link, and then click Edit Page.
In the Federated Results Web Part instance you want to modify, click the edit arrow to display the Web Part menu, and then click Edit Web Part.
In the Federated Results Web Part tool pane, expand the Display Properties section.
Select Use Location Visualization.
Click OK to update the Federated Results Web Part instance.
Before you can enable HTML rendering, you must understand the structure of both the XML that is returned to the Federated Results Web Part and the XSLT that transforms the XML. To learn how to edit the XSL property of a federated location or Web Part, see How to: View and Edit the Search Results XSLT Transformation. To view the search results XML that is returned by a federated location, follow the instructions in How to: View Search Results XML Data.
Verify that the XML node whose data you want to display contains HTML. Next, notice that this HTML is not displayed on the page because the XSLT is removing HTML. For example, the following tag inside the GetPlainTextFromHtml template removes HTML tags from the description field of an RSS feed, as follows.
Modify the <xsl:value-of> tag to output the $Html value without calling the GetPlainTextFromHtml template.
The default XSLT for an OpenSearch location displays the title, link, and description fields of an OpenSearch RSS feed. Make this change for only the description field of a typical RSS or ATOM feed. For information about customizing the title display, see How to: Customize the Title and Branding Icon for Federated Search Results.
After you save this change to the federated location or Federated Results Web Part, HTML tags are displayed as escaped characters on the page. For example, you will see angle brackets (<>) instead of the rendered HTML. The next step explains how to change this behavior.
Find the <xsl:value-of> tag whose output you want to display. For example, to display HTML from the description field of an RSS or ATOM feed, find the following tag.
Add the disable-output-escaping attribute, as follows.
The disable-output-escaping attribute causes the <xsl:value-of> tag to output HTML without any escaping of characters. This could result in HTML output that is not well-formed. Therefore, use this attribute with caution and to display only valid HTML from trusted sources.
Because the $DescText value in the tag you edited earlier is a truncated value, the HTML code in the description field might be truncated before the tagging is complete. This would cause the HTML to render incorrectly.
To ensure that the HTML renders correctly, modify the select value for the tag so that it uses the value that is not truncated.