Atom feed XSL stylesheet example
November 27, 2011 12:43:24 Last update: November 27, 2011 12:59:01
An easy to digest stylesheet example for XSLT for Atom. Simply list entry titles and summary:
To show the first 3 items in atom feed:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <!-- supress default text node output --> <xsl:template match="text()"/> <xsl:template match="/atom:feed/atom:entry"> <h2> <a href="{atom:link/@href}"> <xsl:value-of select="atom:title" disable-output-escaping="yes"/> </a> </h2> <div> <xsl:value-of select="substring(atom:updated, 0, 11)"/> </div> <div> <xsl:value-of select="atom:summary" disable-output-escaping="yes"/> </div> </xsl:template> </xsl:stylesheet>
To show the first 3 items in atom feed:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <!-- supress default text node output --> <xsl:template match="text()"/> <xsl:template match="/atom:feed"> <xsl:for-each select="atom:entry[position() <= 3]"> <h2> <a href="{atom:link/@href}"> <xsl:value-of select="atom:title" disable-output-escaping="yes"/> </a> </h2> <div> <xsl:value-of select="substring(atom:updated, 0, 11)"/> </div> <div> <xsl:value-of select="atom:summary" disable-output-escaping="yes"/> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet>