I'm using SharePoint Foundation 2010 and we've added a blog as a subsite. I want to show a 'recent blog posts' webpart on the main site page, so decided to go down the route of an XML webpart using the rss feed from the blog.
This is working great, except the date format returned by the rss feed is like:
Wed, 02 May 2012 09:22:36 GMT
I just want it to be dd/MM/yyyy.
I tried referencing the ddwrt namespace in the header of the xsl file, but when I try to use:
ddwrt:FormatDate($item_date,1033,1)
to format the date, but I'm just getting 'Failed to apply XSLT to the content' whenever I do. works fine, and the ddrwrt reference I copied from an existing xsl file in SharePoint.
entire xsl (it's only short, don't worry!):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" ddwrt:oob="true">
<xsl:output method="html" indent="no"/>
<xsl:template match="/">
<div>
<xsl:apply-templates select="rss/channel"/>
</div>
</xsl:template>
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<ul>
<xsl:apply-templates select="item"/>
</ul>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<xsl:variable name="item_author" select="author"/>
<xsl:variable name="item_date" select="pubDate"/>
<xsl:if test="position() < 6">
<li>
<a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a><br />
<span class="blog-date">
<xsl:value-of select="$item_date"/>
</span>
<br/>
<span class="blog-author">
<xsl:value-of select="author"/>
</span>
</li>
</xsl:if>
</xsl:template>
If I change line 25 to:
<xsl:value-of select="$item_date" />
Then I get no errors, but the date is obviously in the full format.
This is day one of working with XSLT, so please be forgiving!
Also, I know that 1033,1 will not give the correct format, but I am just using it as a placeholder for now until I get the code working.