Friday, April 6, 2012

How to modify Sharepoint’s result page by XSL

As I wrote (in italian) in this post: http://salvatoredifaziosharepoint.blogspot.it/2010/09/aggiungere-un-campo-nei-risultati-di.html
We can have custom columns value as a result of our search if we add those in the mapped crawler properties.
After the site was crawled, through this xsl:
<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>


we can check if the value is into xml.

Now is the time to make a shape of our result.
To do that we need to make a xsl stylesheet.

In this post I don’t teach to you XSL (you can take a look here) but I will take your attention in how VS2010 works with it.

One of the most boring step todo with XSL is check if the generated XSLT is what we expect.

Maybe is better to write was a boring step because with Visual Studio we can debug the XSL and check step-by-step the result.

First of all we must open the xsl file in Visual Studio (I use the 2010 version):

xsl-04-04-2012 17-27-36

In the properties windows specify the data source:

xml-propeties-04-04-2012 17-35-24

Now we can add breakpoint in our xsl, debug it and check the result:

xml-debug-04-04-2012 17-38-00



For more information take a look at: http://msdn.microsoft.com/en-us/library/ms255602(v=vs.100).aspx

No comments:

Post a Comment