<%@ page isELIgnored="true" %> <%@ taglib uri="cms" prefix="cms" %> RSS and Reporting

RSS and Reporting

A report designed for RSS will need RSS-style rows. RSS works nicely with the report system since requests for reports are all done using HTTP GETS. The generated URLs will work for an automated connection. A context script that checks for the presence of those rows can be helpful.

Typical context script for an RSS (2.0) feed
import com.urbancode.anthill3.domain.reporting.*; ReportOutput output = 
   (ReportOutput) 
context.get("output"); // validate that the report can be turned into a 
   RSS feed if 
(!output.hasColumn("title") || !output.hasColumn("date") || 
   !output.hasColumn("link") || 
!output.hasColumn("guid") || !output.hasColumn("description")) 
   { throw new Exception
   ("The report output 
does not support the RSS template"); } context.put("pubDate", new Date());

With the context script done, you then pair it with the RSS template (similar to what is below):

RSS template paired with context script
<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>$report.Name</title>
    <link>$reportUrl</link>
    <description>$report.Description</description>
    <language>en-us</language>
    <pubDate>$pubDate</pubDate>
    <generator>Anthill3</generator>
#foreach($row in $output.RowArray)
    <item>
      <title>$row.getColumnValue("title")</title>
      <link>$row.getColumnValue("link")</link>
      <description>$row.getColumnValue("description")</description>
      <pubDate>$row.getColumnValue("date")</pubDate>
      <guid>$row.getColumnValue("guid")</guid>
    </item>
#end
  </channel>
</rss>