Solved

XSL Question for Displaying People Search in SharePoint

Posted on 2007-11-21
9
2,261 Views
Last Modified: 2013-11-18
I am using an XSL Stylesheet to describe the results I get from a SharePoint People Search.  The view of the the data coming across is good - I just need to add a new field.  The following represents the CURRENT XSL code:

****************** ORIGINAL CODE  *************************
        <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>

-- and then later on..--

<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" />  
   <br/>
  </xsl:if>

  <xsl:if test='string-length($dep) &gt; 0'>  
   <xsl:value-of select="$dep" />  
   <br/>
  </xsl:if>
  <xsl:if test='string-length($office) &gt; 0'>  
   <xsl:value-of select="$office" />
   <br/>
  </xsl:if>
  <xsl:if test='string-length($phone) &gt; 0'>  
   <xsl:value-of select="$phone" />  
  </xsl:if>
  </span>
  <br/>
</xsl:template>
********************  END ORIGINAL CODE ***************************
This works - it displays all the information from the SharePoint Personal Profiles and all the property fields display properly.

I need to add a new field called "OfficeName" to immediately follow the Office field.  Here is what I coded for that:

********************  NEW CODE ****************************
        <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:with-param name="oname" select="officename" />
          </xsl:call-template>
        </div>

--and a little later down --

<xsl:template name="DisplayOfficeProfile">
  <xsl:param name="title" />
  <xsl:param name="dep" />
  <xsl:param name="phone" />
  <xsl:param name="office" />
  <xsl:param name="oname" />

  <span class="psrch-Metadata">
  <xsl:if test='string-length($title) &gt; 0'>  
   <xsl:value-of select="$title" />  
   <br/>
  </xsl:if>
  <xsl:if test='string-length($dep) &gt; 0'>  
   <xsl:value-of select="$dep" />  
   <br/>
  </xsl:if>
  <xsl:if test='string-length($office) &gt; 0'>  
   <xsl:value-of select="$office" /> - <xsl:value-of select="$oname" />    
   <br/>
  </xsl:if>
  <xsl:if test='string-length($phone) &gt; 0'>  
   <xsl:value-of select="$phone" />  
  </xsl:if>
  </span>
  <br/>
</xsl:template>

***********************  END NEW CODE *********************

The value for "OfficeName" do not show up (the also-added dash does appear). The value is there internally, however, because I can go to the People search page and use the following as an example for a search..

Smith officename="El Paso, TX"

...and I do indeed get the list of Smiths who work out of the El Paso office.  However, the value does not show up on the screen display.  Therefore I am convinced it has to do with the way I am showing it in the XSL stylesheet.

But I don't see my error.  Anybody see my probably-very-simple mistake?

I appreciate all your help - Thanx!
0
Comment
Question by:DBaileyFoxGal
  • 5
  • 4
9 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
I think the key is here
           <xsl:with-param name="oname" select="officename" />
I assume the param oname doesn't get a value

there are various possible reasons for that
all having a similar conclusion, in the current context "officename" does not exist

thinks to check
- is there a namespace involved?
- is there a mixed case (XML is case sensitive)
- is officename at a deeper level? eg. in an address child

I can only evaluate that if I see a snippet of the original XML

cheers

Geert
0
 

Author Comment

by:DBaileyFoxGal
Comment Utility
Thanx for the rapid response.

I think you are right when you say that "officename does not exist.  From your suggested things to review, I can only immediately respond to one - I don't think there is a case-sensitive issue here.  The only references to "oname" and "officename" are code snippets I put in the question description and they seem okay.

Your other two suggestions may be the issue but to be honest, I'm pretty green when it comes to XML and XSL.  

How can I tell if there is a namespace involved with these fields?
How can I tell if officename is in an address child?

If there is another piece of the original XML you need to see, please review the attached ORIGINAL code below.

Thanx!






 

This is the original XSLT that resided in the XSL editor of the Core Search Results Web Part..
 
 
 

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

<xsl:param name="ResultsBy" />

<xsl:param name="ViewByUrl" />

<xsl:param name="ViewByValue" />

<xsl:param name="IsNoKeyword" />

<xsl:param name="IsFixedQuery" />

<xsl:param name="MoreResultsText" />

<xsl:param name="MoreResultsLink" />

<xsl:param name="CollapsingStatusLink" />

<xsl:param name="CollapseDuplicatesText" />

<xsl:param name="MeHeaderValue" />

<xsl:param name="CollHeaderValue" />

<xsl:param name="CollOfCollHeaderValue" />

<xsl:param name="EveryoneHeaderValue" />

<xsl:param name="AddToMyColleaguesText" />

<xsl:param name="SrchRSSText" />

<xsl:param name="SrchRSSLink" />

<xsl:param name="ShowMessage" />

<xsl:param name="ShowActionLinks" />
 

<!-- When there is keywory to issue the search -->

<xsl:template name="dvt_1.noKeyword">

  <span class="ms-sbplain">

  <xsl:choose>

  <xsl:when test="$IsFixedQuery">

      Please set the 'Fixed Query' property for the webpart.

  </xsl:when>

   <xsl:otherwise>

      Enter one or more words to search for in the search box.

   </xsl:otherwise>

  </xsl:choose>

  </span>       

</xsl:template>
 
 

<!-- When empty result set is returned from search -->

 <xsl:template name="dvt_1.empty">

<xsl:if test="$ShowActionLinks">

 <div class="srch-sort">

  <xsl:if test="string-length($SrchRSSLink) &gt; 0">     

   <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL"><img border="0" src="/_layouts/images/rss.gif" alt=""/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-of select="$SrchRSSText"/></a>

  </xsl:if>

 </div>

</xsl:if>

 <br/> <br/>
 

  <span class="ms-sbplain" id="CSR_NO_RESULTS">

   No results matching your search were found.
 

    <ol>

    <li>Check your spelling. Are the words in your query spelled correctly?</li>

    <li>Try using synonyms. Maybe what you're looking for uses slightly different words.</li>

    <li>Make your search more general. Try more general terms in place of specific ones.</li>

    <li>Try your search in a different scope. Different scopes can have different results.</li>

    </ol>

  </span>

</xsl:template>
 
 

<!-- Main body template. Sets the Results view (Relevance or date) options -->

<xsl:template name="dvt_1.body">

  <xsl:if test="$ShowActionLinks">

  <div class="srch-sort"> <xsl:value-of select="$ResultsBy" /> 

   <xsl:if test="$ViewByUrl">  

     |     

    <a href ="{$ViewByUrl}" id="CSR_RV" title="{$ViewByValue}">

     <xsl:value-of select="$ViewByValue" />

    </a>  

   </xsl:if>

   <xsl:if test="string-length($SrchRSSLink) &gt; 0">     

     | 

     <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL"><img border="0" src="/_layouts/images/rss.gif" alt=""/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:value-of select="$SrchRSSText"/></a>

   </xsl:if>

   </div>

   <div style="margin-top: 15px;"></div>

   <br /> <br />

  </xsl:if>

  

  <xsl:apply-templates />

  

  <xsl:call-template name="DisplayMoreResultsAnchor" />

</xsl:template>
 
 

<!-- This template is called for each result -->

<xsl:template match="All_Results/Result">

  <xsl:variable name="id" select="id"/>

  <xsl:variable name="url" select="url"/>

  <xsl:variable name="email" select="workemail"/>

  <xsl:variable name="sip" select="sipaddress"/>

  <xsl:variable name="prefix">IMNRC('</xsl:variable>

  <xsl:variable name="suffix">')</xsl:variable>

  <table class="psrch-result" CELLPADDING="0" CELLSPACING="0" BORDER="0" width="100%">

    <tr>

      <td class="psrch-imgcell" width="0%">

        <table class="psrch-profimg" CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="77px" HEIGHT="77px">

          <tr>

            <td align="middle" valign="middle">

              <a href="{$url}" id="{concat('CSR_IMGL_',$id)}" title="{$url}">

                <xsl:variable name="imgid" select="concat('CSR_IMG_',$id)"/>

                <xsl:choose>

                  <xsl:when test="pictureurl[. != '']">

                    <img id="{$imgid}" src="{pictureurl}" alt="{preferredname}" border="0" onload="resizeProfileImage('{$imgid}')"/>

                  </xsl:when>

                  <xsl:otherwise>

                    <img id="{$imgid}" src="/_layouts/images/no_pic.gif" alt="{preferredname}" border="0" onload="resizeProfileImage('{$imgid}')"/>

                  </xsl:otherwise>

                </xsl:choose>

                <script>

                  window.setTimeout("resizeProfileImage('<xsl:value-of select="$imgid"/>')", 1)

                </script>

              </a>

            </td>

          </tr>

        </table>

      </td>

      <td valign="top" class="psrch-propcell" width="100%">

        <span class="psrch-Title">

          <xsl:choose>

           <xsl:when test="sipaddress[. != '']">

             <img border="0" height="12" width="12" src="/_layouts/images/imnhdr.gif" onload="{concat($prefix, $sip, $suffix)}" ShowOfflinePawn="1" id="{concat('CSRP_',$id,',type=sip')}" />

           </xsl:when>

          <xsl:otherwise>

            <img border="0" height="12" width="12" src="/_layouts/images/imnhdr.gif" onload="{concat($prefix, $email, $suffix)}" ShowOfflinePawn="1" id="{concat('CSRP_',$id,',type=smtp')}" />

         </xsl:otherwise>

        </xsl:choose>

          <a href="{$url}" id="{concat('CSR_',$id)}">

            <xsl:value-of select="preferredname"/>

          </a>

        </span>

        <br/>

        <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="hithighlightedsummary[. != '']">

              <xsl:apply-templates select="hithighlightedsummary" />

              <br/>

            </xsl:when>

            <xsl:when test="aboutme[. != '']">

              <xsl:value-of disable-output-escaping="yes" select="aboutme"/>

              <br/>

            </xsl:when>

          </xsl:choose>

           <xsl:choose>

            <xsl:when test="responsibility[. != ''] or skills[. != '']">

              <xsl:choose>

                <xsl:when test="responsibility[. != '']">

                  <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="skills[. != '']">

                  <xsl:if test="responsibility[. != ''] and skills[. != '']">

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

            <xsl:call-template name="DisplayCollapsingStatusLink">

              <xsl:with-param name="status" select="collapsingstatus"/>

              <xsl:with-param name="url" select="$url"/>

            </xsl:call-template>

            <xsl:choose>

              <xsl:when test="addtomycolleaguesurl[. != '']">

                <xsl:call-template name="DisplayAddToMyColleaguesLink">

                  <xsl:with-param name="url" select="addtomycolleaguesurl"/>

                </xsl:call-template>

              </xsl:when>

            </xsl:choose>

          </span>

          <br/>

        </div >

      </td>

    </tr>

  </table>          

</xsl:template>
 

<xsl:template name="HitHighlighting"> 

 <xsl:param name="hh" /> 

 <xsl:apply-templates select="$hh"/> 

</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 match="All_Results/DummyResult/Me">

    <span class="srch-SocDistTitle">

	<xsl:value-of select="$MeHeaderValue" />

    </span>

   

</xsl:template> 
 

<xsl:template match="All_Results/DummyResult/Colleague">

    <span class="srch-SocDistTitle">

	<xsl:value-of select="$CollHeaderValue" />

    </span>

   

</xsl:template> 

<xsl:template match="All_Results/DummyResult/ColleagueOfColleague">

    <span class="srch-SocDistTitle">

	<xsl:value-of select="$CollOfCollHeaderValue" />

    </span> 

</xsl:template>

<xsl:template match="All_Results/DummyResult/Everyone">

    <span class="srch-SocDistTitle">

	<xsl:value-of select="$EveryoneHeaderValue" />

    </span> 

</xsl:template>
 

<!-- The size attribute for each result is prepared here -->

<xsl:template name="DisplaySize">

  <xsl:param name="size" /> 

  <xsl:if test='string-length($size) &gt; 0'>       

   <xsl:if test="number($size) &gt; 0">

   - <b>

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

    </b>

   </xsl:if>

  </xsl:if>

</xsl:template>
 

<!-- The "view more results" for fixed query -->

<xsl:template name="DisplayMoreResultsAnchor">

  <xsl:if test="$MoreResultsLink">

   <a href="{$MoreResultsLink}">

    <xsl:value-of select="$MoreResultsText"/> 

    </a>

   </xsl:if>

</xsl:template>
 

<xsl:template name="DisplayAddToMyColleaguesLink">

    <xsl:param name="url"/>

       <a href="{$url}">

          <xsl:value-of select="$AddToMyColleaguesText"/>

       </a><br/>

</xsl:template>
 

<!-- document collapsing link setup -->

<xsl:template name="DisplayCollapsingStatusLink">

    <xsl:param name="status"/>

    <xsl:param name="url"/>

    <xsl:if test="$CollapsingStatusLink">

      <xsl:choose>

          <xsl:when test="$status=1">

              <br/>

              <xsl:variable name="CollapsingStatusHref" select="concat(substring-before($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'), 'duplicates:&quot;', $url, '&quot;', substring-after($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'))"/>

              [<a href="{$CollapsingStatusHref}" title="{$CollapseDuplicatesText}">

              <xsl:value-of select="$CollapseDuplicatesText"/>

              </a>]

          </xsl:when>

      </xsl:choose>

    </xsl:if>

</xsl:template>
 

<!-- XSL transformation starts here -->

<xsl:template match="/">

  <xsl:choose>

   <xsl:when test="$IsNoKeyword = 'True'" >

    <xsl:call-template name="dvt_1.noKeyword" />

   </xsl:when>

   <xsl:when test="$ShowMessage = 'True'">

     <xsl:call-template name="dvt_1.empty" />

   </xsl:when>

   <xsl:otherwise>

    <xsl:call-template name="dvt_1.body"/>      

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

<!-- End of Stylesheet -->

</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
can you also post the XML that you use for transformation source?
0
 

Author Comment

by:DBaileyFoxGal
Comment Utility
As I mentioned, I am pretty green at this.

The XSL code I pulled from a People Search Core Results web part on a Sharepoint page.  I don't see anything THERE to get the XML transformation code.

Where would I find this?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
well, it could be possible that you have no access to the source XML
in that case, replace the XSLT with this one

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node()">
    <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>

This way, the output will be exactly what the input is
(you will need a safe source if you view that in a browser)

cheers

Geert

0
 

Author Comment

by:DBaileyFoxGal
Comment Utility

I inserted the code you sent into the XSL editor of the web part.  As expected, it sent a lot of output.  The following is a small portion of it that represents one people search result --

3FOXGAL.COM\dmadriga215EC582-A32D-4449-97FA-231089F61ADBMadrigal, DavidFraming Installer Iii7101http://mosstest/mysite/Person.aspx?guid=215EC582-A32D-4449-97FA-231089F61ADBhttp%3A%2F%2Fmosstest%2Fmysite%2FPerson%2Easpx%3Fguid%3D215EC582%2DA32D%2D4449%2D97FA%2D231089F61ADBDavid Madrigal, David http://mosstest/mysite/Person.aspx?guid=215EC582-A32D-4449-97FA-231089F61ADB/_layouts/images/html16.gifjavascript:AddToColleagues('foxgal.com\\dmadriga')

As can be seen here, the "officename" information is not coming across.  We are getting other fields such as "jobtitle" ("Framing Installer III" seen at the end of the first line) and "officenumber" ("7101" immediately following the jobtitle).  But if "officename" were present, we would be seeing "San Antonio Construction" which we don't.

That value ("San Antonio Construction") can be seen in the Sharepoint Personal Profile for this associate.  The property field is also marked as "indexed" so it should be picked up during a search crawl.  Apparently I am still missing something at this level.

Also - if I go through the People Search feature of SharePoint, I can request the following search argument: 'david officename:"San Antonio Construction" '  and I get this person to come up alone (as opposed to all David's).  So I believe the value is making it's way into the search crawl properly.  It is just not making it into the output of the XSL.

Any ideas?
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
Comment Utility
This XSLT literally copies the input XML
This means that the problem is not in your earlier XSLT
But sharepoint is not copying this new field to the XML output
(in other words, SharePoint might have the indexed field available and searchable, it does not put it in the XML output)
I am afraid I can't help you with that.
Maybe you should post a link (or a new question) in the SharePoint zone

cheers

Geert
0
 

Author Comment

by:DBaileyFoxGal
Comment Utility

Thanx so much for your help - I have solved the problem - your help in narrowing me down to the solution was the real help I needed.

Solution:  In the People Core Search web part, there is a field called "Selected Columns" which appeared to be empty.  However, when I selected it, a pop-up text box opened where the "hidden" code was seen.  Within this code was a list of the fields that were coming across on the XML document.  "Officename" was not there.  After I added it, everything worked great!

The reason the "Seclected Columns" box looked empty was because the first several characters were blank disguising the actual contents.

Many thanx for your help!

0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
welcome
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now