Philadelphia Reflections

The musings of a physician who has served the community for over six decades

Related Topics

No topics are associated with this blog

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 https://24ways.org/2006/beautiful-xml-with-xsl -->

<xsl:stylesheet version="1.0"
  xmlns:xsl="https://www.w3.org/1999/XSL/Transform"
  xmlns:atom="https://www.w3.org/2005/Atom"
  xmlns:dc="https://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="https://www.philadelphia-reflections.com/stylesheets/rssxsl.css" type="text/css"/>
      <link rel="stylesheet" href="https://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="https://www.philadelphia-reflections.com/images/Newsfeed-Atom-24x24.png" alt="ATOM feed icon" /> 
        This is the <strong>ATOM-feed </strong> 
        for the <a href="https://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='https://add.my.yahoo.com/rss?url=' + window.location;return false;">
                <img height="17" width="91" vspace="3" border="0" alt="my yahoo" src="https://www.philadelphia-reflections.com/images/addtomyyahoo4.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='https://www.bloglines.com/sub/'+ window.location;return false;">
                <img height="18" width="91" vspace="3" border="0" alt="bloglines" src="https://www.philadelphia-reflections.com/images/rss-bloglines.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='https://www.newsgator.com/ngs/subscriber/subext.aspx?url='+ window.location;return false;">
                <img height="17" width="91" vspace="3" border="0" alt="newsgator" src="https://www.philadelphia-reflections.com/images/rss-newsgator.gif"/>
              </a><br/>
              <a href="#" onClick="window.location='https://client.pluck.com/pluckit/prompt.aspx?GCID=C12286x053&amp;a=' + window.location + '&amp;t={title}';return false;">
                <img src="https://www.philadelphia-reflections.com/images/pluspluck.png" vspace="3" border="0" alt="Subscribe with Pluck RSS reader"/>
              </a><br/>
              <a href="#" onClick="window.location='https://www.rojo.com/add-subscription?resource=' + window.location;return false;">
                <img src="https://www.philadelphia-reflections.com/images/rss-rojo.gif" vspace="3" border="0" alt="Subscribe in Rojo"/>
              </a><br/>
              <a href="#" onClick="window.location='https://fusion.google.com/add?feedurl=' + window.location;return false;">
                <img src="https://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>

Originally published: Thursday, April 09, 2009; most-recently modified: Thursday, November 08, 2012

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