WSS and RSS

If we're only running WSS and not the MOSS components, we don't get the RSS Viewer web part.

So we have to build our own out of the XML viewer web part and then we have to have an XSLT to render the feed's XML on screen.

So, I'm have a little trouble with this.

First, I've got a custom list called MyList with just an Item Title column and a Description column.

Now, under List Settings I check the RSS Settings.  If RSS isn't allowed at the Site, Site Collection or WebApp level in Central Admin, you won't see the RSS Settings for the list.

So RSS is allowed and I'm checking Select All columns and click OK.

I'm back at my list and I click on the Actions menu.  I select View RSS Feed and I get the pretty rss feed page with a URL that looks like: http://MyServer/_layouts/listfeed.aspx?List=<some guid>.

So, I copy the URL to the feed to my clipboard and I move to a web part page and add an XML Viewer web part.  I open the tool pane and paste my URL in the XML Link field and click OK.

What I end up with is a style-free version of the pretty rss feed page inside my web part.  So, at this point, I simply need to transform my XML with and XML Style Sheet also called an XSLT.

OK, the simplest XSLT I've been able to come up with looks like this:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<a href="{link}">
<xsl:value-of select="title"/></a>
<BR/>
<xsl:value-of select="pubDate"/>
<BR/><BR/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

So, since my problem is that I get the pretty rss feed page instead of the real XML, I now have to guess what's going on.  And my guess is this:

  1. For some reason, I have to browse out to http://www.w3.org/1999/XSL/Transform and get version "1.0".  I don't get that part but it's required.
  2. Then I do this xsl:template thing that matches "/".  I guess I'm going to build within this template something related to the root of my XML file.
  3. Next, I do this xsl:for-each thing that selects "rss/channel/item" which, I suppose, lives at the root of my XML file.  Inside, this for each, I'll get code repeated each time an "item" is encountered.
  4. Inside this for-each node, I'm going to create an anchor tag with a magical {link} href and use the "title" column to provide the text for the link.  Then, I'm going to insert a line break and add the contents of the "pubdate" field as text.  Then, I'm going to do two line breaks to skip a line between items.

The text in my webpart looks like this:

Item Four
Thu, 13 Dec 2007 16:28:49 GMT

Item Three
Thu, 13 Dec 2007 16:28:40 GMT

Item Two
Thu, 13 Dec 2007 16:28:31 GMT

Item One
Thu, 13 Dec 2007 16:28:21 GMT

Perfect.

Except for two things.

First, I'd like to get my description to appear.

Second, I don't have a "title" or a "pubdate" column in my list.

The description is easy.  I just add this to my XSLT:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<a href="{link}">
<xsl:value-of select="title"/></a>
<BR/>
<xsl:value-of select="description">

<BR/>
<xsl:value-of select="pubDate"/>
<BR/><BR/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

So this works, but not as expected.  Apparently, the rss feed generates all the content into the "description" node. because I get four items that look like this:

Item Four
<div><b>Description:</b> Description for Item Four</div> <div><b>Content Type:</b> Item</div> <div><b>Created:</b> 12/13/2007 11:28 AM</div> <div><b>Created By:</b> MyServer
obot</div> <div><b>Item Title:</b> Item Four</div> <div><b>Modified:</b> 12/13/2007 11:30 AM</div> <div><b>Modified By:</b> MyServer
obot</div> <div><b>Version:</b> 1.0</div>
Thu, 13 Dec 2007 16:28:49 GMT

I also note that it matters that I use the "description" selector and not the "Description" selector; apparently it's case sensitive.

So, even though I included all my fields, I can't get my Description field and I can't seem to get any of the other fields like "Created" or "Modified By".  I usually end up with a blank line there, given that I used a <BR/> tag.  In fact if I try a field with a space in too, like "Modified by" the XSLT blows up completely giving me the helpful bit of advice:

The XSL specified by the XSL property or XSL Link property is not valid, or the XSL file cannot be accessed. Make sure you have specified a valid XSL style sheet for this Web Part, or if the XSL file is linked that it can be accessed by the server. For assistance, contact your site administrator. More about making XSL files accessible

Needless to say, I do not recommend you try the "More about" link.

It seems like, if I could see the XML that the rss feed generates instead of that pretty rss feed page, if i could see the raw XML, I'd be able to figure out how to work down the nodes to the item node and then get the values out of the my columns.

So, if you're follwoing along, you know we can just save our pretty rss feed page as an XML file and I've opened mine in FrontPage and see that all I will ever get from my list is the title, pubdate, author and such while the real data, like my item's Description (with a capital "D") is all rolled into an XML "description" node that uses a ![CDATA operator and parses all my item data into a single field that looks like HTML but it's really just text.  So, really, any hope of having an RSS feed generate something intelligent like an item and it's description are looking pretty remote.

grrrr…

-robot

 


Tags:

 
 
 

Comments are closed.