Friday, August 20, 2010

Modifying the ItemStyle.xsl causes the Summary Links Webpart to crash.

Scenario : An additional presentation template was added for rendering the Content Query Webpart which used the shared parameter value SiteUrl to build the link. The template was good enough and the content query webpart worked perfectly. But interestingly soon after this change, the Summary Links webpart stopped working. It showed this message "Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator."

While checking the ULS (Unified Logging Service) Log files under in 12 Hive\Logs folder, the error logged was this,
“w3wp.exe (0x015C)  0x06B0    Windows SharePoint Services       Web Parts                         89a1    Monitorable    Error while executing web part: System.Xml.Xsl.XslLoadException: The variable or parameter 'SiteUrl' is either not defined or it is out of scope. An error occurred at http://servername/Style Library/XSL Style Sheets/ItemStyle.xsl(471,4).     at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)     at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform() “

What was happening was that while transforming the Summary Links webpart (which didn't used the new XSL template added) it kept crashing since it couldn't find the variable SiteUrl.

Solution: If you are willing to unghost the xsl files then use sharepoint designer to open the SummaryLinkMain.xsl (which can be found under Style Library\XSL Style Sheets folder in designer) or if you are worried about unghosting then find the SummaryLinkMain.xsl under the 12 Hive folder, TEMPLATE\FEATURES\PublishingResources.
Open the file SummaryLinkMain.xsl in any text editor, and find the top section where the <xsl:param ... /> tags can be seen.
Append the following tag just below any existing <xsl:param ... /> tag
<xsl:param name="SiteUrl" />

Save the file and Refresh the file if you have unghosted using Sharepoint Designer, else do an IISRESET and then refresh the page.

Now the Summary Links webpart is back to working without any issues.

More Information: The MSDN document has mentioned how the xsl files are related.

http://msdn.microsoft.com/en-us/library/ms551040.aspx

No comments: