Sharepoint RSS ticker

One of the MOSS 2007 SharePoint web parts is an RSS or XML web part which can take XML content and transform it. Making a new ticker was tricky in 2003, though there was a nice solution I found here.

In the new web part you can use this code to display a simple HTML marquee element based on the RSS content found:

<xsl:stylesheet xmlns:x="https://www.w3.org/2001/XMLSchema" xmlns:d="https://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl ddwrt msxsl" xmlns:ddwrt="https://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="https://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" indent="no"/>

<xsl:template match="/" xmlns:x="https://www.w3.org/2001/XMLSchema" xmlns:d="https://schemas.microsoft.com/sharepoint/dsp">
<xsl:call-template name="ticker"/>
</xsl:template>

<xsl:template name="ticker">
<xsl:variable name="StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/rss/channel/item"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<xsl:variable name="IsEmpty" select="$RowCount = 0"/>
<xsl:choose>
<xsl:when test="$IsEmpty">
<xsl:call-template name="empty"/>
</xsl:when>
<xsl:otherwise>

<table border="0" width="100%" cellpadding="2" cellspacing="0" class="ms-nav">
<tr>
<td class="ms-vb">

<marquee direction="right" onMouseover="this.scrollAmount=2" onMouseout="this.scrollAmount=6">
<xsl:call-template name="tickerBody">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="FirstRow" select="1"/>
<xsl:with-param name="LastRow" select="$RowCount"/>
</xsl:call-template>
</marquee>

</td>
</tr>
</table>

</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="tickerBody">
<xsl:param name="Rows"/>
<xsl:param name="FirstRow"/>
<xsl:param name="LastRow"/>
<xsl:variable name="GroupStyle" select="'auto'"/>

<xsl:for-each select="$Rows">
<!-- insert your own preferred image here -->
<img src="_layouts/images/navlink.gif" mce_src="_layouts/images/navlink.gif" border="0"/>
<img src="_layouts/images/blank.gif" mce_src="_layouts/images/blank.gif" height="1" width="10" alt="Icon" border="0"/>
<a style="display:{$GroupStyle}">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<font>
<!-- change this to have a fixed style
<xsl:attribute name="size">
<xsl:value-of select="@Font_x0020_Size"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:if test="@Bold &gt; 0">font-weight:Bold;</xsl:if>
<xsl:if test="@Italics &gt; 0">font-style:Italic;</xsl:if>
</xsl:attribute>
<xsl:attribute name="color">
<xsl:value-of select="@Color"/>
</xsl:attribute>-->
<xsl:value-of select="title"/>
</font>
</a>
<img src="_layouts/images/blank.gif" mce_src="_layouts/images/blank.gif" height="1" width="20" alt="Icon" border="0"/>
<!-- add this line below for up marquee
<br/>
-->
</xsl:for-each>
</xsl:template>

<xsl:template name="empty">
<xsl:variable name="ViewEmptyText">There are no current announcements.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$ViewEmptyText"/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>