PHILADELPHIA REFLECTIONS
Musings of a Philadelphia Physician who has served the community for six decades

Return to Home

Related Topics

Website Development
The website technology supporting Philadelphia Reflections is PHP, MySQL and DHTML. The web hosting service is Internet Planners. The development of this website has provided an opportunity to learn new technology, to try out different techniques for getting noticed by the search engines and the trials and tribulations of dealing with malicious hackers and spammers who range from the annoying to the abusive. This collection of articles documents some of our experiences and we hope that people surfing the web looking for solutions to problems we've encountered will benefit.

Stylesheet for ATOM feed

Even though neither IE 7 nor Firefox 3.0.8 will render a stylesheet for an ATOM or RSS feed delivered over the network, we have set them up in hopes that someday this anomaly will be cured.

No aggregator I have ever seen goes to the basic trouble of sorting their input feeds by modified date, relying on the feed creator to "push" the latest onto the top of the stack. Our XSL stylesheet does sort by modified date, among other nice things.

Here's the XSL stylesheet for our ATOM feed, including sorting the entries:

<?xml version="1.0" encoding="utf-8"?>

<!--                                   -->
<!--     Philadelphia Reflections      -->
<!--   XSL Stylesheet for ATOM feed    -->
<!--                                   -->

<!-- Grateful acknowledgement to http://24ways.org/2006/beautiful-xml-with-xsl -->

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/">
  
    <xsl:output method="html" encoding="utf-8"/>
	
    <xsl:template match="/">
      <html>
      <head>
      <title>ATOM Feed for Philadelphia Reflections</title>
      <link rel="stylesheet" href="http://www.philadelphia-reflections.com/stylesheets/rssxsl.css" type="text/css"/>
      <link rel="stylesheet" href="http://www.philadelphia-reflections.com/stylesheets/images.css" type="text/css"/>
      <style type="text/css">
        .notvisible {visibility: hidden;}
      </style>
      </head>
      <body>
        <xsl:apply-templates select="/atom:feed"/>
      </body>
      </html>
    </xsl:template>
	
    <xsl:template match="/atom:feed">
      <div class="topbox">
        <p><img src="http://www.philadelphia-reflections.com/images/Newsfeed-Atom-24x24.png" alt="ATOM feed icon" /> 
        This is the <strong>ATOM-feed </strong> 
        for the <a href="http://www.philadelphia-reflections.com/"><xsl:value-of select="atom:title"/></a>
        website.<br />
        ATOM feeds allow you to stay up to date with the latest additions and changes 
        on  <xsl:value-of select="atom:title"/>.</p>
      </div>
        
      <div class="contbox">
        <table><tr>
          <td>
            <div class="mainbox">
            <div class="itembox">
              <h1><xsl:value-of select="atom:title"/></h1>
              <p><xsl:value-of select="atom:subtitle"/></p>

              <ul id="entries">
                <xsl:apply-templates select="atom:entry">
                  <xsl:sort select="atom:updated" order="descending"/>
                </xsl:apply-templates>
              </ul>

            </div>
            </div>
          </td>

          <td valign="top" width="30%">
            <div class="subscrbox">
            <div class="padrhsbox">
              <h2>Subscribe to this feed</h2>
              <p>If you use one of the following web-based News Readers,
                click on the appropriate button to subscribe to the RSS feed.</p>
              <a href="#" onClick="window.location='http://add.my.yahoo.com/rss?url=' + window.location;return false;">
                <img height="17" width="91" vspace="3" border="0" alt="my yahoo" src="http://www.philadelphia-reflections.com/images/addtomyyahoo4.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='http://www.bloglines.com/sub/'+ window.location;return false;">
                <img height="18" width="91" vspace="3" border="0" alt="bloglines" src="http://www.philadelphia-reflections.com/images/rss-bloglines.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='http://www.newsgator.com/ngs/subscriber/subext.aspx?url='+ window.location;return false;">
                <img height="17" width="91" vspace="3" border="0" alt="newsgator" src="http://www.philadelphia-reflections.com/images/rss-newsgator.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='http://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&amp;a=' + window.location + '&amp;t={title}';return false;">
                <img src="http://www.philadelphia-reflections.com/images/pluspluck.png" vspace="3" border="0" alt="Subscribe with Pluck RSS reader"/>
              </a><br/>
              <a href="#" onClick="window.location='http://www.rojo.com/add-subscription?resource=' + window.location;return false;">
                <img src="http://www.philadelphia-reflections.com/images/rss-rojo.gif" vspace="3" border="0" alt="Subscribe in Rojo"/>
              </a><br/>
              <a href="#" onClick="window.location='http://fusion.google.com/add?feedurl=' + window.location;return false;">
                <img src="http://gmodules.com/ig/images/plus_google.gif" vspace="3" border="0" alt="Add to Google"/>
              </a>
              <hr />
              <p>If you would like to receive an email whenever changes are made, please send me an email and I'll be glad to add you. 
              <br /><br /><a href="mailto:grfisheriii@gmail.com?subject=Add%20me%20to%20Philadelphia%20Reflections%20email%20list">Click to send an email</a></p>
            </div>
            </div>
          </td>

        </tr></table>

      </div>
    </xsl:template>
	
    <xsl:template match="atom:entry">
      <li style="margin-bottom: 25px; height: auto;">
        <a href="{atom:link/@href}">
          <xsl:value-of select="atom:title"/>
        </a>
        <small>
          &#8212; <xsl:value-of select="substring-before(atom:updated,'T')"/>
        </small>
        <br/>
        <div class="item_desc">
          <xsl:value-of select="atom:summary" disable-output-escaping="yes"/> <!-- disable-output-escaping="yes" does not work with Firefox 3.0.8 -->
        </div>
      </li>
    </xsl:template>

</xsl:stylesheet>

(1616)

Thanks, this is a good stylesheet for Atom xml!
Posted by: Fabio   |   Nov 8, 2012 5:25 AM

Please Let Us Know What You Think


(HTML tags provide better formatting)

Because of robot spam we ask you to confirm your comment: we will send you an email containing a link to click. We apologize for this inconvenience but this ensures the quality of the comments. (Your email will not be displayed.)
Thank you.