Bruno Grange
Bruno Grange
"Imagination is more important than knowledge." (Einstein)

Content
Social
| Creating an RSS 1.0 news feed in Domino R5 |
|
|
| Written by Bruno Grange |
| Tuesday, 02 September 2008 23:13 |
|
When Netscape invented its portal a few years back, it invented a light-weight text based description language that web sites could produce so that Netscape servers could easily get information from remote information systems. What they did was to produce a universal way for developers to describe their site's content. The description language that Netscape developed became known as RDF Site Summary (RSS), sometimes referred to incorrectly as (Rich Site Summary). It uses XML and the Resource Description Framework (RDF), a hierarchical data model used for describing web-based information. RSS 0.90 was the first version, released in March 1999, the latest version (at the time of writing) is version 1.0 which was released as a W3C standard in September 2000. This article will focus on the syntax of RSS v1.0. The structure of RSS An RSS document starts with an XML declaration and an Rdf tag. Following this are the XML namespace declarations, think of these as "includes" which define the tags allowed. Next is the channel tag which describes the data included in the feed, followed by the feed items themselves. The basic structure that follows comprises of the main tags of RSS v1.0. XML Declaration <rdf:RDF> XML name space declarations <channel rdf:about="[LINK TO THIS FEED]"> <title></title> <description></description> <link></link> </channel> <image rdf:about="[URL TO IMAGE/LOGO"> (OPTIONAL) <title></title> <url></url> <link></link> </image> <item rdf:about="[LINK TO ITEM]"> <title></title> <description></description> <link></link> </item> other items repeated? </rdf:RDF> I am not going to go into the specific syntax of RSS here as the RSS 1.0 specification includes a very simple reference guide to syntax. The syntax and structure is simple enough to read that you can take an existing example and map your data to it to get you started. In most cases this will suffice for everything you need to do. Producing RSS from Domino Creating the items view As you can see from the structure outline above RSS effectively consists of a header of information (the <channel> tag) an image or logo for the feed and a series of items. As the headers are almost static we need to concern ourselves with getting the items. The series of items translate to a set of documents in a view. You need to create a view with 2 columns, one for sorting by date and one for the content. The second column consists of the fields we want and the tags that surround them. The first column contains your date field for sorting purposes, this field should be hidden. The second column contains the following... <item rdf:about="URL TO DOCUMENT"> <date>DATE OF DOCUMENT</date> <title>TITLE OF DOCUMENT</title> <description>TEXT OF DOCUMENT</description> <link>URL TO DOCUMENT</link> </item> The view column formula should look something like this. "<item rdf:about=\"http://www.notestips.com/db.nsf/view/" + @Text(@DocumentUniqueID) +"\"><date>" + vUTCDate + "</date><title>notestips | " + doc_title + "</title><description>" + doc_text + "</description><link>http://www.notestips.com/db.nsf/view/" + @Text(@DocumentUniqueID) + "</link></item>" N.B.: Date formats: RSS v1.0 feeds require a special date format known as UTC (Universal Time Coordinated) which is formatted as follows, 2003-04-30T19:20:30Z. Please refer to my article "UTC Date Format using @Functions and LotusScript" on how to create UTC date formats using @Formula. In the formula above the UTC date should be assigned to the variable vUTCDate. Tip: If your description contains just a link, an <a href="/url"></a>, to the document rather than an actual text description, the source page will be loaded ans displayed immeadiately inside news readers such as NewzCrawler, rather than than displaying the text description and a URL link that you have to click on to get the web page! View Properties There are two view properties to set. The first is to not show the column headings and the second is more crucial, you must check the box "Treat view content as HTML" on the advanced tab. For the remainder of this article I will asume you have saved the View with the name "RSSFeed". Combining the items with the header When you have created your view of items you need to combine that with the RSS header information. To do this simply copy the example header you see below onto a Page in Domino Designer, modify the values (as per instructions below) and then embed your view into it. When modifying the header it is best not to change the ?xml and the xmlns lines, these are XML namespace declarations that define the rss syntax. RSS Header <?xml version="1.0" encoding="utf-8"?> <rdf:RDF xmlns:h="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> <channel rdf:about="[URL TO THIS PAGE]"> <title>[TITLE OF THIS FEED]</title> <description>[THE DESCRIPTION OF THIS FEED]</description> <link>[URL TO YOUR HOMEPAGE]</link> <date>[DATE OF LAST ENTRY]</date> </channel> <image rdf:about="[URL TO YOUR LOGO]"> <title>>[TITLE OF YOUR SITE]</title> <url>[URL TO YOUR LOGO]</url> <link>[LINK TO GOTO WHEN CLICKING ON THE IMAGE]</link> </image> [EMBED YOUR VIEW HERE] </rdf:RDF> N.B. When using this header replace everything inside and including the square brackets with your own data, see below for more details on specifying the date. Modifying the RSS header date information To modify the values of the example header simply replace everything inside and including the square brackets with your own data. Most of these are self explainitory but the date of the feed requires a lookup to find out the publication date of the most recent entry in the feed. <date>[DATE OF LAST ENTRY]</date> This should be some ComputedText that does a DBColumn to retrieve the most recent articles date. The formula is as follows... vDate := @Subset(@DbColumn("";"";"RSSFeed";1);1); vDate However, as with item dates this date should be in UTC (Universal Time Coordinated) which is formatted as follows, 2003-04-30T19:20:30Z. Please refer to my article "UTC Date Format using @Functions and LotusScript" on how to create UTC date formats using @Formula. Page Properties When creating your page make sure it has the following properties set. 1. When you name the page call it "myfeed.rss" 2. Check the page property "Treat page contents as HTML" Embedded View Properties When embedding your view make sure it has the following properties set. 1. Display using HTML 2. Set the "Lines to display" to 10 to limit the number of entries dsplayed in the view. 3. Check "Show content only (don't show title)" Viewing the feed Now you can save your page and make a note of it's URL. You can now use that URL to create a new channel in your rss reader such as NewzCrawler or FeedReader. Please be aware that as-it-is (with R5) the URL will NOT open in a web browser. If you have a need to allow the contents of the .rss feed to be visible on the web then read the next section, if not you can stop now! Creating a Style Sheet A browser will get confused when trying to read the content of the .rss Page when servered from a Domino databse in R5 format. Mainly because the content of the Page is XML but the Page is being served by the Domino server as HTML because of the "Treat page contents as HTML" Page property. The content of the Page is not really HTML at all, it's XML, more specifically it is rss+xml, but R5 does not allow that as an option. In R6 this IS possible and if you createing your feeds in R6 please see my article "Creating an RSS v2.0 news feed in Domino R6". A way around the problem is to use a style sheet that will convert the XML into styles that the browser can understand and insert a reference to it on the header of the RSS feed. The style sheet declaration comes straight after the very first line of the header, <?xml version="1.0" encoding="utf-8"?>. Immeadiately after this put the following line, edited to the URL of your stylesheet. <?xml-stylesheet href="http://YOURSEVER/db.nsf/YOURSTYLESHEET.css" type="text/css"?> You can make the style sheet a page in the same database that contains your RSS feeds. An example stylesheet, which you can copy and paste, is below. rss, channel, item, title, description, link { display: block; } image, language, managingEditor, webMaster, docs, copyright, lastBuildDate, pubDate, rating, day, hour, skipDays, skipHours, textinput, name { display: none; } rdf { } channel { color: #FFFFFF; background-color: #004B6C; padding:5px; width:50em; margin-top:3px; } item { background-color: #F1F1F1; padding:5px; width:50em; margin-top:3px; } title { text-align:left; margin-top:5px; margin-bottom:3px; font-family: verdana, arial, sans-serif; font-size:18px; font-weight:bold; } description { margin-top: 6pt; font-style: italic; font-family: verdana, arial, sans-serif; font-size:16px; } link { margin-top: 6pt; font-family: verdana, arial, sans-serif; text-decoration: underline; font-size:12px; } date { font-family: verdana, arial, sans-serif; font-size:12px; } If you use the stylesheet provided you will be able to click on the URLs and see a result in the browser. Conclusion RSS is a compact simple and easy to use format which is extremely functional. Hopefully using this article you have the knowledge to create your own feeds and spread the RSS word. Useful Links Documentation RDF Specification RSS 1.0 Specification Associating Style Sheets with XML documents Version 1.0 How to add style to XML (Some) RSS News Readers 1. NewzCrawler 2. FeedReader 3. Headline Reader The RSS News Feeds provided by notestips.com News http://www.notestips.com/80256B3A007F2692/rss-news.rss New articles and tips http://www.notestips.com/80256B3A007F2692/rss-articlestips.rss New comments http://www.notestips.com/80256B3A007F2692/rss-comments.rss Related Articles: |

