Compartilhar via


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:

  • Federated Results

  • 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

  1. On the Search Administration page, click Federated Locations.

  2. Under Location Display Name, right-click the name of your location, and then click copy.

  3. 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).

  4. Expand the Display Information node.

  5. Under Core Search Results Metadata, clear the Use Default Formatting check box.

  6. 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

  1. In your browser, navigate to the results page URL, as follows:

    https://ServerName/SiteName/Pages/results.aspx

  2. Click the Site Actions link, and then click Edit Page.

  3. 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.

  4. In the Display Properties section, clear the Use Location Visualization check box.

    Important

    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.

  5. 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.

Note

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.