Xml template
When implementing custom XSLT templates I almost always need to know the XML output of the controls or webparts to customize. Some of the webpart shows examples of the XML output, but most of the time this is useless. Based on the webpart settings different XML is emitted from the webpart. To get the actual XML I use a small XSLT template that renders the XML output:
<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>
Adding this template to a webpart will render the XML output based on the current webpart settings.
ContentQueryWebPart
There are situations where the XSLT shown above will not do the trick and here I am thinking about the ContentQueryWebPart. This web part is rendered using several XSLT templates found in the Styles Library in SharePoint. To render the output from the ContentQueryWebPart you need to modify the ItemStyle XSLT. Here is the template I use for this purpose:
<pre style="margin-left:1em">
<xsl:text><</xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:apply-templates select="@*"/>
<xsl:text>></xsl:text>
<xsl:apply-templates/>
<xsl:text></</xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:text>></xsl:text>
</pre>
</xsl:template>
<xsl:template match="@*">
<xsl:text> </xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"</xsl:text>
</xsl:template>
For details on customizing the ContentQueryWebPart and ItemStyle template, you to take a look at this post by Heather Solomon. She does a great job of explaining the details.
Recent Comments