Yesterday, I described the steps to drop the Search Core Results Web Part on a page of a WSS 3.0 team site and have it configured with a fixed query. Let me continue with that example but go a step further and customize the way the results are displayed to the user.

The list of results returned by the search service is in XML format. This XML output can be reviewed in the Search Core Results Web Part itself by replacing the default XSLT (using the toolpane with the properties exposed by the Web Part) with the following:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xmp><xsl:copy-of select="*"/></xmp>

</xsl:template>

</xsl:stylesheet>

If you run the query now, the output will look like this:

Creating a custom XSLT for this XML can be done in a number of ways. If you are an XSLT geek, open NotePad and start writing your pattern-matching rules. There are however plenty of XSLT editors available that can help you in this and possibly even come up with a nice transformation without writing any line of XSLT.

What I will demonstrate here is how you can make use of the SharePoint Designer 2007 to come up with an XSLT for this XML.

First of all, just copy the XML in a local file since you'll need it in a minute.

Next open the SharePoint Designer 2007 and the site containing the page you are working with. The Search Core Web Part is like many other MOSS 2007 Web Parts (for example the Business Data Web Parts) based on the Data View Web Part. This is a Web Part you can only create in the SharePoint Designer. Before doing this however, you have to create a data source. The data source to create is one that connects to the file containing the raw XML outputted by the search Web Part. There is a menu called Data View in the SharePoint Designer. Use it to open the Data Sources panel. In that panel, you'll see a link to create a new XML data source. Just point to the XML file and import it in the site. You'll not need it anymore later - it is just needed as the sample XML for the generation of the XSLT.

In the Data Sources panel, select to option in the context menu of the XML data source, to show the data. A new panel is activated showing all of the XML nodes available in the XML file. Use all of that information now to insert a Data View Web Part on one of your pages. Again, you do not need that Web Part to stay on the page. We'll simply steal the generated XSLT from this one and use it to replace the XSLT of the Search Core Results Web Part.

The Data View Web Part allows for many customizations. For example, you can configure it to show the results grouped by author. Many other formatting and styling configurations are possible.
Bottom-line is that you can have a peek in the code view and copy all of the XSLT that is generated by the Data View Web Part.

Go back to a page where you have the Search Core Results Web Part (this can also be the search results page in the Search Center) and replace the active XSLT with the copied one.
Here is a possible outcome:

Message to take away from this posting is.. there is a quick way to come up with XSLT or the Search Core Results Web Part by making use of the Data View Web Part in the SharePoint Designer.