c3d2-web/xsl/podcast.xsl

100 lines
3.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- Spezifikation:
http://www.apple.com/itunes/store/podcaststechspecs.html
-->
<xsl:stylesheet version="1.0"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl date">
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:include href="date.xsl" />
<xsl:variable name="baseurl">https://www.c3d2.de/</xsl:variable>
<xsl:template match="news">
<rss version="2.0">
<channel>
<title>C3D2 Podcast</title>
<link><xsl:value-of select="$baseurl"/>radio.html</link>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<description>Pentaradio als MP3</description>
<itunes:subtitle>Pentaradio als MP3</itunes:subtitle>
<itunes:summary>Radio vom CCC Dresden</itunes:summary>
<language>de</language>
<itunes:image href="{$baseurl}images/ck.png" />
<itunes:category text="Talk">
<itunes:category text="Radio"/>
</itunes:category>
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" />
<!--xsl:if test="position() &lt;= 10"-->
<xsl:if test="count(document(.)/item/resource) &gt; 0">
<xsl:apply-templates select="document(.)/item">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
</channel>
</rss>
</xsl:template>
<xsl:template match="item">
<xsl:param name="newsfile"/>
<item>
<xsl:variable name="href">
<xsl:value-of select="$baseurl"/>
<xsl:value-of select="substring-before(substring-after($newsfile, 'content/'), '.xml')"/>
<xsl:text>.html</xsl:text>
</xsl:variable>
<title><xsl:value-of select="@title"/></title>
<link><xsl:value-of select="$href"/></link>
<author><xsl:value-of select="@author"/></author>
<guid isPermaLink="true"><xsl:value-of select="$href"/></guid>
<pubDate>
<xsl:call-template name="date-to-rfc822">
<xsl:with-param name="date" select="@date"/>
</xsl:call-template>
</pubDate>
<xsl:apply-templates select="resource" mode="preselect"/>
</item>
</xsl:template>
<xsl:template match="resource" mode="preselect">
<xsl:choose>
<xsl:when test="count(alternative[@type='audio/mpeg']) &gt; 0">
<xsl:apply-templates test="alternative[@type='audio/mpeg'][1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[name(.) = 'resource' or name(.) = 'alternative']">
<enclosure
url="{translate(@url, ' ', '+')}"
length="{@size}"
type="{@type}"
/>
</xsl:template>
</xsl:stylesheet>