<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:srrt="http://schemas.microsoft.com/WebParts/v3/srchrss/runtime" xmlns:media="http://search.yahoo.com/mrss/" xmlns:search="http://schemas.microsoft.com/SharePoint/Search/RSS" version="1.0">
  <xsl:param name="channelTitle"/>
  <xsl:param name="channelDescription"/>
  <xsl:param name="channelDescriptionNoResults"/>
  <xsl:param name="rssGenerator"/>
  <xsl:param name="queryKeyword"/>
  <xsl:param name="queryScope"/>
  <xsl:param name="srchResultPage"/>
  <xsl:param name="locale"/>
  <xsl:param name="channelImageUrl"/>
  <xsl:param name="lastBuildDate"/>
  <xsl:param name="clientTransformStyleSheet"/>
  <xsl:param name="noTitle"/>
  <xsl:param name="siteUrl"/>
  <xsl:param name="styleSheetLink"/>
  <xsl:param name="defaultpeoplescopetitle"/>  

  <xsl:template match="/">    
    <xsl:variable name="Rows" select="/All_Results/Result" />
    <xsl:variable name="RowCount" select="count($Rows)" />
    <xsl:variable name="IsEmpty" select="$RowCount = 0" />

    <xsl:variable name="StyleSheetRef1" select="string('&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;')" />
    <xsl:variable name="StyleSheetRef2" select="string('&quot; version=&quot;1.0&quot;?&gt;')" />
    <xsl:variable name="StyleSheetRef" select="concat($StyleSheetRef1, $clientTransformStyleSheet, $StyleSheetRef2)" />

    <xsl:value-of disable-output-escaping="yes" select="$StyleSheetRef" />
    <rss version="2.0">
      <channel>
        <title>
          <xsl:value-of select="$channelTitle" />          
        </title>
        <link>
          <xsl:value-of disable-output-escaping="yes" select="$srchResultPage" />
        </link>
        <xsl:choose>
          <xsl:when test="$IsEmpty">
            <description>
              <xsl:value-of select="$channelDescriptionNoResults" />
            </description>
          </xsl:when>
          <xsl:otherwise>
            <description>
              <xsl:value-of select="$channelDescription" />
            </description>
          </xsl:otherwise>
        </xsl:choose>        
        <language>
          <xsl:value-of select="$locale" />
        </language>
        <lastBuildDate>
          <xsl:value-of select="$lastBuildDate" />
        </lastBuildDate>
        <generator>
          <xsl:value-of select="$rssGenerator" />
        </generator>
        <ttl>60</ttl>
        <image>
          <title>
            <xsl:value-of select="$channelTitle" />
          </title>
          <url>
            <xsl:value-of disable-output-escaping="yes" select="$channelImageUrl" />
          </url>
          <link>
            <xsl:value-of disable-output-escaping="yes" select="$srchResultPage" />
          </link>
        </image>

        <xsl:choose>
          <xsl:when test="$IsEmpty">            
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="GenerateItems">
              <xsl:with-param name="Rows" select="$Rows" />
              <xsl:with-param name="RowCount" select="$RowCount" />
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>

      </channel>
    </rss>        
  </xsl:template>

  <xsl:template name="GenerateItems">
    <xsl:param name="Rows" />
    <xsl:param name="RowCount" />

    <xsl:variable name="IsPeopleScope" select="$queryScope = $defaultpeoplescopetitle"/>

    <xsl:for-each select="$Rows">
      <item>
        <title>
          <xsl:choose>
            <xsl:when test="$IsPeopleScope">
              <xsl:call-template name="RenderByCondition">
                <xsl:with-param name="Condition" select="string-length(preferredname) &gt; 0"/>
                <xsl:with-param name="TrueValue" select="preferredname"/>
                <xsl:with-param name="FalseValue" select="$noTitle"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="RenderByCondition">
                <xsl:with-param name="Condition" select="string-length(title) &gt; 0"/>
                <xsl:with-param name="TrueValue" select="title"/>
                <xsl:with-param name="FalseValue" select="$noTitle"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </title>

        <link>          
          <xsl:call-template name="RenderByCondition">
            <xsl:with-param name="Condition" select="string-length(url) &gt; 0"/>
            <xsl:with-param name="TrueValue" select="srrt:EnsureIsAllowedProtocol(url)"/>
            <xsl:with-param name="FalseValue" select="$srchResultPage"/>
          </xsl:call-template>
        </link>        

        <description>
          <xsl:variable name="CDATASTART" select="string('&lt;![CDATA[')" />
          <xsl:variable name="CDATAEND" select="string(']]&gt;')" />

          <xsl:value-of disable-output-escaping="yes" select="$CDATASTART" />
          <div style="margin-top:5px">
            <link rel="stylesheet" type="text/css" href="{srrt:EnsureIsAllowedProtocol($styleSheetLink)}"/>
            <xsl:choose>
              <xsl:when test="$IsPeopleScope">
                <table class="psrch-result" CELLPADDING="0" CELLSPACING="0" BORDER="0" width="100%">
                  <tr>
                    <td valign="top" class="psrch-imgcell">
                      <a href="{srrt:EnsureIsAllowedProtocol(url)}">
                        <xsl:choose>
                          <xsl:when test="string-length(pictureurl) &gt; 0">
                            <img src="{srrt:EnsureIsAllowedProtocol(pictureurl)}" border="0" width="40"/>
                          </xsl:when>
                          <xsl:otherwise>
                            <img src="{concat($siteUrl, '/_layouts/images/no_pic.gif')}" border="0" width="40"/>
                          </xsl:otherwise>
                        </xsl:choose>
                      </a>
                    </td>
                    <td valign="top=" class="psrch-propcell ms-inputuserfield" width="100%" style="border:0px">
                      <div class="psrch-Description">
                        <xsl:call-template name="DisplayOfficeProfile">
                          <xsl:with-param name="title" select="jobtitle" />
                          <xsl:with-param name="dep" select="department" />
                          <xsl:with-param name="phone" select="workphone" />
                          <xsl:with-param name="office" select="officenumber" />
                        </xsl:call-template>
                      </div>

                      <div class="psrch-Description">
                        <xsl:choose>
                          <xsl:when test="string-length(hithighlightedsummary) &gt; 0">
                            <xsl:apply-templates select="hithighlightedsummary" />
                            <br/>
                          </xsl:when>
                          <xsl:when test="string-length(aboutme) &gt; 0">
                            <xsl:value-of disable-output-escaping="yes" select="aboutme"/>
                            <br/>
                          </xsl:when>
                        </xsl:choose>

                        <xsl:variable name="HasResponsibility" select="string-length(responsibility) &gt; 0"/>
                        <xsl:variable name="HasSkills" select="string-length(skills) &gt; 0"/>
                        <xsl:choose>
                          <xsl:when test="$HasResponsibility or $HasSkills">
                            <xsl:choose>
                              <xsl:when test="$HasResponsibility">
                                <span class="psrch-PropLabel">
                                  <xsl:text>Responsibilities: </xsl:text>
                                </span>
                                <span class="psrch-PropValue">
                                  <xsl:value-of select="translate(responsibility,';',',')"/>
                                  <xsl:text> </xsl:text>
                                </span>
                              </xsl:when>
                            </xsl:choose>

                            <xsl:choose>
                              <xsl:when test="$HasSkills">
                                <xsl:if test="$HasResponsibility and $HasSkills">
                                  <br/>
                                </xsl:if>
                                <span class="psrch-PropLabel">
                                  <xsl:text>Skills: </xsl:text>
                                </span>
                                <span class="psrch-PropValue">
                                  <xsl:value-of select="translate(skills,';',',')"/>
                                </span>
                              </xsl:when>
                            </xsl:choose>
                            <br/>
                          </xsl:when>
                          <xsl:otherwise>
                            <span />
                          </xsl:otherwise>
                        </xsl:choose>
                      </div>

                      <div class="psrch-Description">
                        <span class="psrch-Action">
                          <xsl:call-template name="DisplaySize">
                            <xsl:with-param name="Size" select="size" />
                          </xsl:call-template>
                        </span>
                        <br/>
                      </div>
                    </td>
                  </tr>
                </table>                                             
              </xsl:when>

              <xsl:otherwise>         

                <xsl:if test="string-length(imageurl) &gt; 0">
                  <xsl:choose>
                    <xsl:when test="string-length(url) &lt; 1">
                      <span class="srch-Icon">
                        <img src="{concat($siteUrl, imageurl)}" alt="{imageurl/@imageurldescription}" border="0"/>
                      </span>
                    </xsl:when>
                    <xsl:otherwise>
                      <span class="srch-Icon">
                        <a href="{srrt:EnsureIsAllowedProtocol(url)}" title="{title}">
                          <img src="{concat($siteUrl, imageurl)}" alt="{imageurl/@imageurldescription}" border="0"/>
                        </a>
                      </span>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:if>

                <xsl:if test="string-length(hithighlightedsummary) &gt; 0">
                  <span class="psrch-Description">
                    <xsl:apply-templates select="hithighlightedsummary"/>
                  </span>
                </xsl:if>

                <xsl:if test="string-length(url) &gt; 0">
                  <p class="srch-Metadata">
                    <span class="srch-URL">
                      <a href="{srrt:EnsureIsAllowedProtocol(url)}" title="{title}">
                        <xsl:value-of select="url" />
                      </a>
                      <xsl:call-template name="DisplaySize">
                        <xsl:with-param name="Size" select="size" />
                      </xsl:call-template>
                    </span>
                  </p>
                </xsl:if>
              </xsl:otherwise>
            </xsl:choose>

          </div>
          <xsl:value-of disable-output-escaping="yes" select="$CDATAEND" />
        </description>

        <xsl:choose>
          <xsl:when test="$IsPeopleScope">

            <xsl:if test="string-length(jobtitle) &gt; 0">
              <xsl:element name="search:jobtitle" >
                <xsl:value-of select="jobtitle" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(workphone) &gt; 0">
              <xsl:element name="search:workphone">
                <xsl:value-of select="workphone" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(officenumber) &gt; 0">
              <xsl:element name="search:officenumber">
                <xsl:value-of select="officenumber" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(aboutme) &gt; 0">
              <xsl:element name="search:aboutme">
                <xsl:value-of select="aboutme" />
              </xsl:element>
            </xsl:if>

            <xsl:choose>
              <xsl:when test="string-length(pictureurl) &gt; 0">
                <xsl:element name="media:thumbnail">
                  <xsl:attribute name = "url" >
                    <xsl:value-of select="pictureurl"/>
                  </xsl:attribute>
                </xsl:element>
              </xsl:when>
              <xsl:otherwise>
                <xsl:element name="media:thumbnail">
                  <xsl:attribute name = "url" >
                    <xsl:value-of select="concat($siteUrl, '/_layouts/images/no_pic.gif')"/>
                  </xsl:attribute>
                </xsl:element>
              </xsl:otherwise>
            </xsl:choose>

            <xsl:if test="string-length(hierarchyurl) &gt; 0">
              <xsl:element name="search:hierarchyurl">
                <xsl:value-of select="hierarchyurl" />
              </xsl:element>
            </xsl:if>

            <xsl:choose>
              <xsl:when test="string-length(sipaddress) &gt; 0">
                <xsl:element name="search:workemail">
                  <xsl:value-of select="workemail" />
                </xsl:element>
              </xsl:when>
              <xsl:otherwise>
                <xsl:if test="string-length(workemail) &gt; 0">
                  <xsl:element name="search:workemail">
                    <xsl:value-of select="workemail" />
                  </xsl:element>
                </xsl:if>
              </xsl:otherwise>
            </xsl:choose>

            <xsl:if test="string-length(hithighlightedsummary) &gt; 0">
              <xsl:element name="search:hithighlightedsummary">
                <xsl:value-of select="hithighlightedsummary" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(responsibility) &gt; 0">
              <xsl:element name="search:responsibility">
                <xsl:value-of select="responsibility" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(skills) &gt; 0">
              <xsl:element name="search:skills">
                <xsl:value-of select="skills" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(schools) &gt; 0">
              <xsl:element name="search:schools">
                <xsl:value-of select="schools" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(pastprojects) &gt; 0">
              <xsl:element name="search:pastprojects">
                <xsl:value-of select="pastprojects" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(interests) &gt; 0">
              <xsl:element name="search:interests">
                <xsl:value-of select="interests" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(orgnames) &gt; 0">
              <xsl:element name="search:orgnames">
                <xsl:value-of select="orgnames" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(orgurls) &gt; 0">
              <xsl:element name="search:orgurls">
                <xsl:value-of select="orgurls" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(orgparentnames) &gt; 0">
              <xsl:element name="search:orgparentnames">
                <xsl:value-of select="orgparentnames" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(orgparenturls) &gt; 0">
              <xsl:element name="search:orgparenturls">
                <xsl:value-of select="orgparenturls" />
              </xsl:element>
            </xsl:if>
          </xsl:when>

          <xsl:otherwise>

            <xsl:if test="string-length(fileextension) &gt; 0">
              <xsl:if test="string-length(size) &gt; 0">
                <xsl:if test="starts-with(url, 'http://')">
                  <xsl:variable name="fileextensioninlowcase" select="translate(fileextension, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
                  <xsl:choose>
                    <xsl:when test="$fileextensioninlowcase='docx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.openxmlformats-officedocument.wordprocessingml.document')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='doc'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/msword')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='docm'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-word.document.macroEnabled.12')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='ppt'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-powerpoint')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='pptx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.openxmlformats-officedocument.presentationml.presentation')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='pptm'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-powerpoint.presentation.macroEnabled.12')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='dot'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/msword')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='xml'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('text/xml')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='xls'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-excel')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vsx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.visio')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vdx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.visio')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='xlsx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='xlsm'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-excel.sheet.macroEnabled.12')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='txt'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('text/plain')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='tiff'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('image/tiff')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='tif'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('image/tiff')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='msg'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/octetstream')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='mht'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('message/rfc822')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vst'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-visio.viewer')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vsd'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-visio.viewer')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vss'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-visio.viewer')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='vtx'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-visio.viewer')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='mhtml'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('message/rfc822')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='eml'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('message/rfc822')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>

                    <xsl:when test="$fileextensioninlowcase='odc'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('text/x-ms-odc')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='pub'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.ms-publisher')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='pdf'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/pdf')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='nsf'">
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/vnd.lotus-notes')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='aspx'">
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='asp'">
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='php'">
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='asmx'">
                    </xsl:when>
                    <xsl:when test="$fileextensioninlowcase='html'">
                    </xsl:when>
                    <xsl:otherwise >
                      <xsl:element name="enclosure">
                        <xsl:attribute name = "url" >
                          <xsl:value-of select="url"/>
                        </xsl:attribute>
                        <xsl:attribute name = "length" >
                          <xsl:value-of select="size"/>
                        </xsl:attribute>
                        <xsl:attribute name = "type" >
                          <xsl:value-of select="string('application/octet-stream')"/>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:if>
              </xsl:if>
            </xsl:if>

            <xsl:if test="contentclass='STS_ListItem_PictureLibrary'">
              <xsl:if test="string-length(pictureurl) &gt; 0">
                <xsl:element name="media:content">
                  <xsl:attribute name = "url" >
                    <xsl:value-of select="pictureurl"/>
                  </xsl:attribute>
                  <xsl:if test="string-length(pictureheight) &gt; 0">
                    <xsl:attribute name = "height" >
                      <xsl:value-of select="pictureheight"/>
                    </xsl:attribute>
                  </xsl:if>
                  <xsl:if test="string-length(picturewidth) &gt; 0">
                    <xsl:attribute name = "width" >
                      <xsl:value-of select="picturewidth"/>
                    </xsl:attribute>
                  </xsl:if>
                  <xsl:if test="string-length(size) &gt; 0">
                    <xsl:attribute name = "fileSize" >
                      <xsl:value-of select="size"/>
                    </xsl:attribute>
                  </xsl:if>
                </xsl:element>
              </xsl:if>
            </xsl:if>

            <xsl:if test="contentclass='STS_ListItem_PictureLibrary'">
              <xsl:if test="string-length(picturethumbnailurl) &gt; 0">
                <xsl:element name = "media:thumbnail" >
                  <xsl:attribute name = "url" >
                    <xsl:value-of select="picturethumbnailurl"/>
                  </xsl:attribute>
                </xsl:element>
              </xsl:if>
            </xsl:if>

            <xsl:if test="string-length(author) &gt; 0">
              <author>
                <xsl:value-of select="author"/>
              </author>
            </xsl:if>

        <xsl:if test="string-length(write) &gt; 0">
          <pubDate>
            <xsl:value-of select="write"/>
          </pubDate>
        </xsl:if>

        <xsl:if test="string-length(keywords) &gt; 0">
          <category>
            <xsl:value-of select="keywords"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag0) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag0"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag1) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag1"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag2) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag2"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag3) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag3"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag4) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag4"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag5) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag5"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag6) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag6"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag7) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag7"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag8) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag8"/>
          </category>
        </xsl:if>

        <xsl:if test="string-length(popularsocialtag9) &gt; 0">
          <category>
            <xsl:value-of select="popularsocialtag9"/>
          </category>
        </xsl:if>

            <xsl:if test="string-length(fileextension) &gt; 0">
              <xsl:element name="search:dotfileextension">
                <xsl:value-of select="concat(&quot;.&quot;, fileextension)" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(size) &gt; 0">
               <xsl:element name="search:size">
                  <xsl:value-of select="size"/>
               </xsl:element>
             </xsl:if>

            <xsl:if test="string-length(hithighlightedsummary) &gt; 0">
              <xsl:element name="search:hithighlightedsummary">
                <xsl:value-of select="hithighlightedsummary" />
              </xsl:element>
            </xsl:if>

            <xsl:if test="string-length(datepicturetaken) &gt; 0">
              <xsl:element name="search:datepicturetaken">
                <xsl:value-of select="datepicturetaken" />
              </xsl:element>
            </xsl:if>

            </xsl:otherwise>
          </xsl:choose>
          </item>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="DisplaySize">
    <xsl:param name="Size" />
    <xsl:if test='string-length($Size) &gt; 0'>
      <xsl:if test="number($Size) &gt; 0">
        -
        <xsl:choose>
          <xsl:when test="round($Size div 1024) &lt; 1">
            <xsl:value-of select="$Size" />Bytes
          </xsl:when>
          <xsl:when test="round($Size div (1024 *1024)) &lt; 1">
            <xsl:value-of select="round($Size div 1024)" />KB
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="round($Size div (1024 * 1024))"/>MB
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:if>
  </xsl:template>

  <xsl:template match="ddd">
    &#8230;
  </xsl:template>
  <xsl:template match="c0">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c1">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c2">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c3">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c4">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c5">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c6">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c7">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c8">
    <b><xsl:value-of select="."/></b>
  </xsl:template>
  <xsl:template match="c9">
    <b><xsl:value-of select="."/></b>
  </xsl:template>

  <xsl:template name="RenderByCondition">
    <xsl:param name="Condition"/>
    <xsl:param name="TrueValue"/>
    <xsl:param name="FalseValue"/>
    <xsl:choose>
      <xsl:when test="$Condition">
        <xsl:value-of select="$TrueValue"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$FalseValue"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="DisplayOfficeProfile">
    <xsl:param name="title" />
    <xsl:param name="dep" />
    <xsl:param name="phone" />
    <xsl:param name="office" />

    <span class="psrch-Metadata">
      <xsl:if test='string-length($title) &gt; 0'>
        <xsl:value-of select="$title" />
        -
      </xsl:if>
      <xsl:if test='string-length($dep) &gt; 0'>
        <xsl:value-of select="$dep" />
        -
      </xsl:if>
      <xsl:if test='string-length($phone) &gt; 0'>
        <xsl:value-of select="$phone" />
        -
      </xsl:if>
      <xsl:if test='string-length($office) &gt; 0'>
        <xsl:value-of select="$office" />
      </xsl:if>
    </span>
    <br/>
  </xsl:template>

</xsl:stylesheet>
