Stripping an Atom RSS Feed

At work, we’ve got an internal-only blog for some upcoming special projects. Our experience, however, is that blogs get ignored without some external notification system like RSS. The problem is that some of our employees use public aggregators like feedly, which cannot see behind our firewall.

Our internal blog generates an RSS feed, but the feed includes <content> and <summary> sections that we really don’t want published in a public RSS feed.

My solution is to copy the feed to a public web host, but massage it with XSLT to remove the sensitive sections.

An atom-based RSS feed is standard XML, albeit with a defined namespace:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">
  <title>Our Internal Blog></title>
  <link href="/atom.xml" rel="self"/>
  <link href=""/>
    <title>Nifty Blog Post</title>
    <link href=""/>
    <content>Stuff we want removed from public view...</content>
    <summary>Short version of stuff we want removed...</summary>

It took me a while to figure out the namespace issues, but here’s the XSL stylesheet that works for me:

<?xml version="1.0"?>
  <!-- strip content and summary elements -->
  <xsl:template match="feed:content"/>
  <xsl:template match="feed:summary"/>
  <!-- print copy of everything else -->
  <xsl:template match="@* | node()">
      <xsl:apply-templates select="@* | node()"/>

I could get rid of the feed: namespace tokens in the template declarations by making feed the default namespace for the stylesheet; the opening declaration would change a bit:


I keep the namespace explicit, however, to remind myself what I’d done when I review this stylesheet later.

The end result of the transformation is a feed that lists largely harmless titles and URLs—so people can be notified of updates—but without leaking any potentially sensitive content.