<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml"/>
  <xsl:template match="/">
    <rss version="2.0">
      <channel>
	<title>Piperka.net blog</title>
	<link>http://piperka.net/blog/</link>
	<description>Site updates and announcements for piperka.net, a webcomic tracker.</description>
	<ttl>600</ttl>
	<xsl:for-each select="/index/post[position() > (last()-15)]">
	  <xsl:variable name="post"><xsl:value-of select="./@href"/>index.xml</xsl:variable>
	  <xsl:variable name="description" select="document($post)//content/*"/>
	  <item>
	    <title><xsl:value-of select="./@title"/></title>
	    <link>http://piperka.net/blog/<xsl:value-of select="./@href"/></link>
	    <guid>http://piperka.net/blog/<xsl:value-of select="./@href"/><xsl:value-of select="./@fragment"/></guid>
	    <pubDate><xsl:value-of select="./@date"/></pubDate>
	    <description><xsl:apply-templates select="document($post)//content/*" mode="escaping"/></description>
	  </item>
	</xsl:for-each>
      </channel>
    </rss>
  </xsl:template>
  <xsl:template match="node()" mode="escaping">&lt;<xsl:value-of select="name(.)"/>
  <xsl:for-each select="./@*">
    <xsl:text> </xsl:text>
  <xsl:value-of select="name(.)" />="<xsl:value-of select="."/>"</xsl:for-each>&gt;<xsl:apply-templates mode="escaping"/>&lt;/<xsl:value-of select="name(.)"/>&gt;</xsl:template>
  <xsl:template match="text()" mode="escaping">
    <xsl:value-of select="."/>
  </xsl:template>
</xsl:stylesheet>
