Create a RSS 2.0 feed with Corinis CMS

Actually this is quite easy. Since the rss format is a xml format you can have a simple xsl to transform the Corinis output into rss.

This example uses the fields header and abstract from the cms and create a nice rss feed for it:

<%
response.setContentType("text/xml");
%><?xml version="1.0"?>
<%@ taglib uri="/corinisTags" prefix="corinis" %>
<rss version="2.0">
<channel>
<title>Examples RSS</title>
<link>http://localhost:8080/</link>
<description>Example rss</description>
<language>en-us</language>

<corinis:cms name="header,abstract" dateFormat="EEE, d MMM yyyy HH:mm:ss z" function="getFileManager" parentFolder="-2" xsl="inline">
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
        <xsl:for-each select="/CMSFILEMANAGER/ENTRY[not(ID=0)]">
                <xsl:sort select="LDATECHANGED" order="descending"/>
        <item>
                <xsl:if test="position() &lt; 5">
                <title><xsl:value-of select="CONTENT/header"/></title>
                <description><xsl:value-of select="CONTENT/abstract"/></description>
                <link>http://localhost:8080/test/observers/index.jsp?Document_id=<xsl:value-of select="ID"/></link>
                <pubDate><xsl:value-of select="DATECHANGED"/></pubDate>
                </xsl:if>
        </item>
        </xsl:for-each>
  </xsl:template>
  </xsl:stylesheet>
</corinis:cms>
</channel>

</rss>

Things to mention

RSS is xml, thus you have to manually set the respone content type to text/xml. This is done in the jsp with

<%
response.setContentType("text/xml");
%>

The next thing you have to take care of is the correct date format. Thankfully you can define whatever date format you want using the dateFormat attribute:

<corinis:cms name="header,abstract" dateFormat="EEE, d MMM yyyy HH:mm:ss z" function="getFileManager" parentFolder="-2" xsl="inline">

With parentFolder="-2" we get a list of all documents available. We sort the tree by LCHANGEDATE (the date of the last change in milliseconds since 1980), and display the first items few as rss.