Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsHow to render RDF style news feeds like slashdot...How to render RDF style news feeds like slashdot...
Previous
 
Next
New Post
2/5/2006 6:08 AM
 

I get emails asking about why some news feeds don't render properly in the News Feeds (RSS) module.  The short answer: probably because of some xsl translation issue.  The second part of setting up a news feed for use by the module involves choosing a translation file to render the feed.  This is somewhat difficult for newbies to get their arms around.  Out of the box DNN supports RSS with an xsl file that renders most RSS feeds in a simple way.  However, not all feeds are simple and may require more effort to render properly. Knowing how to examine a new feed source file is important to effectively using those types of feeds.

One such type of rss news feed variation is commonly referred to as an rdf style.  You can do a google search to get details on this implementation, so I won't go into that here.  What I want to share is a simple xsl file that will render most types of rdf document news feeds. The example can be used for most similar types of rdf feeds, but may have to be further tweaked depending on the the namespaces and elements used in the actual feed.

 I've used it most recently for rendering and displaying the RSS feeds from this url, which is a link from Slashdot's home page at the bottom lableled RSS.

http://rss.slashdot.org/Slashdot/slashdot

Here's the xsl:

<?xml version='1.0'?>
<xsl:stylesheet
  version="1.0" exclude-result-prefixes="rdf rss l dc admin content xsl"
                xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
                xmlns:rdf="
http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                  xmlns:rss="
http://purl.org/rss/1.0/"
                xmlns:dc="
http://purl.org/dc/elements/1.1/"
                  xmlns:admin="
http://webns.net/mvcb/"
                  xmlns:l="
http://purl.org/rss/1.0/modules/link/"
                  xmlns:content="
http://purl.org/rss/1.0/modules/content/">
<!-- phil 'iwonder' guerra - xsl simple rdf translation file. -->
    <xsl:output omit-xml-declaration="yes"/>
    <xsl:template match="/rdf:RDF">
       <xsl:for-each select="rss:item">   
    <xsl:variable name="mylink" select="rss:link"/>
      <xsl:variable name="mytitle" select="rss:title"/>
             <h3 style="color:#cc0000; clear:left;">       
                <a class="headlines">    
      <strong>     
     <a href="{$mylink}" title="{$mytitle}"><xsl:value-of select="rss:title" /></a>
            </strong>     
                </a>  </h3>  
            <font size="-1">
                <xsl:value-of disable-output-escaping="yes" select="rss:description"/></font>
                <br/>
               <span class="date"><font size="-1">
                   Published: <xsl:value-of select="dc:date"/></font>
                </span>       
            <hr/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

There's a host of variations, but hopefully, the example gives you some ideas to further explore rendering similar rdf news feeds.

Cheers,

 

 
New Post
3/2/2006 2:30 PM
 
Just a note to say "Thank You" for this. I didn't understand what the Style field was when I was setting up RSS. I thought it was the path to a CSS or something. RSS on my site wasn't valuable enough for me to purchase a 3rd party module, but with your help I was able to add it for free.

I truly hope to see more and more helpful individuals like yourself on these forums.

Regards,

Jared
 
New Post
3/20/2006 10:51 AM
 

How would you go about including the top items on the feed for credit and displaying the site image?

 

- <channel rdf:about="http://slashdot.org/">
  <title>Slashdot</title>
  <link>http://slashdot.org/</link>
  <description>News for nerds, stuff that matters</description>
  <dc:language>en-us</dc:language>
  <dc:rights>Copyright 1997-2006, OSTG - Open Source Technology Group, Inc. All Rights Reserved.</dc:rights>
  <dc:date>2006-03-20T15:11:00+00:00</dc:date>
  <dc:publisher>OSTG</dc:publisher>
  <dc:creator>pater@slashdot.org</dc:creator>
  <dc:subject>Technology</dc:subject>
  <syn:updatePeriod>hourly</syn:updatePeriod>
  <syn:updateFrequency>1</syn:updateFrequency>
  <syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>
- <items>
- <rdf:Seq>
  <rdf:li rdf:resource="http://linux.slashdot.org/article.pl?sid=06/03/20/141259&from=rss" />
  <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/03/20/1354258&from=rss" />
  <rdf:li rdf:resource="http://games.slashdot.org/article.pl?sid=06/03/20/1223233&from=rss" />
  <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/03/20/0656257&from=rss" />
  <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/03/20/1216233&from=rss" />
  <rdf:li rdf:resource="http://yro.slashdot.org/article.pl?sid=06/03/20/0638242&from=rss" />
  <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/03/20/0647221&from=rss" />
  <rdf:li rdf:resource="http://hardware.slashdot.org/article.pl?sid=06/03/20/0646209&from=rss" />
  <rdf:li rdf:resource="http://hardware.slashdot.org/article.pl?sid=06/03/20/0320249&from=rss" />
  <rdf:li rdf:resource="http://science.slashdot.org/article.pl?sid=06/03/20/0311242&from=rss" />
  </rdf:Seq>
  </items>
  <image rdf:resource="http://images.slashdot.org/topics/topicslashdot.gif" />
  <textinput rdf:resource="http://slashdot.org/search.pl" />
  </channel>
- <image rdf:about="http://images.slashdot.org/topics/topicslashdot.gif">
  <title>Slashdot</title>
  <url>http://images.slashdot.org/topics/topicslashdot.gif</url>
  <link>http://slashdot.org/</link>
  </image>
 
New Post
3/21/2006 3:00 PM
 

There are a number of ways to do it.  Try working with this more advanced Slashdot stylesheet.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet exclude-result-prefixes="rdf rss l dc admin content xsl"
  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                  xmlns:rss="http://purl.org/rss/1.0/"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:rss09="http://my.netscape.com/rdf/simple/0.9/"
                 xmlns:admin="http://webns.net/mvcb/"
                  xmlns:l="http://purl.org/rss/1.0/modules/link/"
                  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<!-- moreRDF - a bit more advanced RDF stylesheet - Phil 'iwonder' Guerra -->
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/rdf:RDF">
                <div>
                <xsl:apply-templates select="rss:channel" />
              </div>
      <div id="newslist">
            <xsl:apply-templates select="rss:item" />
    </div>        </xsl:template>
        <xsl:template match="rss:channel">
                <xsl:variable name="link" select="rss:link"/>
                <xsl:variable name="description" select="rss:description"/>
                <xsl:variable name="image" select="/rdf:RDF/rss:image/rss:url"/>
                 <xsl:variable name="rightsPeriod" select="substring-before(dc:rights,',')"/>
                <xsl:variable name="rightsPhrase" select="substring-before(dc:rights,'All ')"/>
      <xsl:variable name="rightsOwner"  select="substring-after($rightsPhrase,', ')" />
               <xsl:if test="$image"> 
                       <a href="{$link}"><img src="{$image}" border="0"  /> </a>
                </xsl:if>
     <br/>
     <font size="3"><xsl:value-of select="rss:description" /></font><br/><br/>
     <xsl:value-of select="$rightsPeriod" /><br/>
     <xsl:value-of select="$rightsOwner" /><br/>
     <xsl:value-of select="substring-after(dc:rights,'Inc. ')" /><br/>
     Last Update: <xsl:value-of select="dc:date" />
                <hr/>
        </xsl:template>
<xsl:template match="rss:item">
           <font size="2"><b><xsl:value-of select="rss:title"/></b></font><br/>
    <font size="1"><b><xsl:value-of select="dc:creator" /></b><br/>
    Published: <xsl:value-of select="dc:date" /></font><br/><br/>
    <xsl:value-of select="rss:description" disable-output-escaping="yes" />
           <xsl:element name="a">
              <xsl:attribute name="href">
                  <xsl:apply-templates select="rss:link"/>
              </xsl:attribute><br/><br/>
       <font size="1">Click for details...</font>       
     </xsl:element>
             <hr/>
</xsl:template>
</xsl:stylesheet>

 

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsNews FeedsNews FeedsHow to render RDF style news feeds like slashdot...How to render RDF style news feeds like slashdot...


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out