Wednesday, January 21, 2009

Modifying SharePoint's ItemStyle.xsl causes problem with Summary Link Web Part

Today I discovered an issue with some customisations I did for a client. The customisations involved changing the ItemStyle.xsl file, to add new templates for a Content Query Web Part.

More specifically, the client wanted to show a view of news items, the latest news item to be displayed in full, and the remaining x number of items to display in summary form.

This can be done with a test for preceding sibling nodes, e.g.

This particular client had one more specific requirement, to also show images associated to the latest News Item. To do this, I created a new XSL variable, pulling in the URL of the image with the following code:
<xsl:variable name="NewsItemImage">
<xsl:call-template name="OuterTemplate.FormatValueIntoUrl">
<xsl:with-param name="Value" select="@ImageUrl">

After some fiddling around with HTML to ensure news items would display in a pleasant manner, I checked in all changes to ItemStyle.xsl, and finished configuring the Content Query Web Part's Item style (under Modify Shared Web Part -> Presentation) to use the new style. All was good in the world.

But, a few days later after the client had begun adding content to the site, they noticed they couldn't add Summary Link Web Parts. All Summary Link Web Parts would display the old "Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint" error message.

After digging around in the SharePoint log files, I found that every time a page that contains a Summary Link Web Part was loaded, the following error would occur:
The named template 'OuterTemplate.FormatValueIntoUrl' does not exist. An error occurred at http://xxx/Style Library/XSL Style Sheets/ItemStyle.xsl(392,10).     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()

So apparently, the OuterTemplate in the of a Summary Link Web Part doesn't have the same <xsl:template>'s defined as the OuterTemplate of a Web Part that sources data from a list. This makes sense, since the links contained in a Summary Link Web Part are stored within the Web Part contents themselves, and not queried from elsewhere in the site.

The solution?

Add a dummy <xsl:template name="OuterTemplate.FormatValueIntoUrl"> element to the bottom of your ItemStyle.xsl. That way, when the Summary Link Web Part tries to validate the contents of ItemStyle.xsl, it has an <xsl:template> to refer to for "OuterTemplate.FormatValueIntoUrl", and when the Content Query Web Part parses the data through the Item Style, it refers to it's real OuterTemplate's <xsl:template> instead. Here's an example of the actual XSL code to add:
<!-- The following is used to fool the summary links web part into thinking the OuterTemplate.FormatValueIntoUrl template exists -->
<xsl:template name="OuterTemplate.FormatValueIntoUrl"></xsl:template>


  1. Thank you - this was so helpful. I had the exact same problem and you just saved me a ton of time.

    Lindy Gibbons

  2. Thanks, I too had this exact problem and am glad that someone posted it up. You saved me a lot of time and frustration.

  3. I've learned since writing this post that the best way to avoid this issue is to use your own ItemStyle.xsl and leave the default SharePoint version intact.

    Heather Solomon ( and the MSDN ( both suggest editing ItemStyle.xsl itself. This is bad in my opinion as its very dificult to back-out the change, say if your modification was deployed via a Site-level feature. If your ItemStyle XSL sits in its own file, its a lot easier to delete.

  4. I had this exact problem too. I'm just wondering if there is a way to prevent "OuterTemplate.FormatValueIntoUrl" from displaying in the 'Item style:' dropdown list within the 'Presentation' section of the sharepoint GUI?