/ #search #SharePoint 2007 

XSLT Tricks

XSLT Tricks header image

Doing the XSLT for SharePoint can be frustrating, especially getting custom site columns or values you’re not sure about if they actually exists in a certain context. For the standard item styles most of you might know the trick:

<xsl:for-each select="@*">
      <xsl:value-of select="name()"/><xsl:value-of select="."/>  <br/>

That let you display all the variables you can access with name and value. Now that makes sense, it allows you to pick the values you want, and put them easily in your xHTML template creating very nice looking views.

Since you can style the search almost the same way as standard XSLT results one would assume you can use the same template to display all the properties accessible from search, too bad that assumption is wrong. The trick would be the following code:

<?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>

It will allow you to get all indexed values that you can use, combining that with adding additional columns you can easily check whether the columns are filled for a specific result set. (By adding columns to the search results you can see if a certain column is filled as you expected).

Loading comments…