How to: View and Edit the Search Results XSLT Transformation
Applies to: SharePoint Server 2010
The Search service application returns the search results to the requesting page as XML data. The search results Web Parts then transform the XML data into the HTML displayed on the results page by using XSLT transformation (XSLT) markup.
You specify the XSLT used to transform the XML data for search results Web Parts that display results data from federated locations in a federated location's XSL property. These Web Parts include the following:
People Search Core Results
Search Core Results
Top Federated Results
You can change how results are displayed in these Web Parts by modifying the XSL property. However, any changes you make in the XSL property are applied to all Web Parts that return search results for that federated location.
You can also configure the XSLT for a specific search results Web Part, so that the changes are reflected only in the Web Part you modify. You can also do this for the Web Parts that display other types of results data, such as the Search Best Bets Web Part, Related Queries Web Part, and Refinement Panel Web Part.
This topic describes how you can modify the XSLT for the federated location or search results Web Part to change how the search results data is displayed.
To modify the XSL property of a federated location
On the Search Administration page, click Federated Locations.
Under Location Display Name, right-click the name of your location, and then click copy.
On the Copy Federated Location page, type a new name for the federated location that indicates that the federated location is emitting only data (for example, Raw XML).
Expand the Display Information node.
Under Core Search Results Metadata, clear the Use Default Formatting check box.
Click the ellipsis (…) button to open the Text Entry window for the federated location's XSL property.
You can modify the XSLT directly in the Text Entry window for the federated location's XSL property. However, you may find it easier to copy the code to a file. You can then edit that file by using an application such as Microsoft Visual Studio 2010. After you edit the file, you can copy the modified code back into the Text Entry window and save your changes to the Web Part.
To access the XSL property of the Web Part
In your browser, navigate to the results page URL, as follows:
Click the Site Actions link, and then click Edit Page.
In the Web Part you want to modify, click the edit arrow to display the Web Part menu, and then click Edit Web Part. This opens the Web Part tool pane.
In the Display Properties section, clear the Use Location Visualization check box.
The Related Queries Web Part, Refinement Panel Web Part, and Best Bets Web Part do not have the Use Location Visualization check box in the tool pane, so this step does not apply to these Web Parts. Instead, for the Refinement Panel Web Part, clear the Use Default Configuration check box in the Refinement section. You do not have to modify anything for the Related Queries Web Part and Best Bets Web Part.
Click the XSL Editor button. The XSL Editor button is located in the Display Properties section for all of the Web Parts, except for the Best Bets and Refinement Panel Web Parts. In those Web Parts, it is located in the Data View Properties section.
This opens the Text Entry window for the Web Part's XSL property. You can modify the XSLT directly in this window; however, you may find it easier to copy the code to a file. You can then edit that file by using an application such as Visual Studio 2010. After editing the file, you can copy the modified code back into the Text Entry window and save your changes to the Web Part.
To revert back to the original code from the XSL property, select the Use Location Visualization check box for the Federated Results Web Part, People Search Core Results Web Part, Search Core Results Web Part, or Top Federated Results Web Part. For the Refinement Panel Web Part, select the Use Default Configuration check box. For the Related Queries Web Part and Best Bets Web Part, you should save a copy of the original XSLT code so that you can easily revert back to the original if needed.
Alternatively, you could add a new instance of the Web Part to the page, because as any modifications you make to the XSL property will apply to only that specific instance of the Web Part.