c3d2-web/xsl/atom.xsl

70 lines
2.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl crypto date">
<xsl:include href="common.xsl" />
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:variable name="baseurl">https://www.c3d2.de/</xsl:variable>
<xsl:template match="news">
<xsl:element name="feed">
<xsl:attribute name="xmlns">http://www.w3.org/2005/Atom</xsl:attribute>
<xsl:attribute name="xml:lang">de</xsl:attribute>
<title>www.c3d2.de Newsfeed</title>
<link rel="self" href="https://www.c3d2.de/news-atom.xml" />
<id>http://www.c3d2.de/</id>
<description>Neues aus dem Chaos Computer Club Dresden</description>
<language>de-de</language>
<!-- XXX
<pubDate><xsl:value-of select="news/item/@date"/></pubDate>
-->
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(.)/@date)" data-type="number" order="descending" />
<xsl:variable name="newsfile" select="."/>
<xsl:for-each select="document(.)/item">
<xsl:call-template name="atom-entry">
<xsl:with-param name="newsfile" select="$newsfile"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="atom-entry">
<xsl:param name="newsfile"/>
<entry>
<id><xsl:value-of select="crypto:sha1(concat(@title,@date))"/></id>
<title><xsl:value-of select="@title"/></title>
<link href="{$baseurl}{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html"/>
<updated><xsl:value-of select="@date"/></updated>
<author>
<name><xsl:value-of select="@author"/></name>
</author>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates/>
</div>
</content>
<xsl:for-each select="resource">
<link
rel="enclosure"
href="{.}"
type="{@type}"
length="{@size}"
/>
</xsl:for-each>
</entry>
</xsl:template>
</xsl:stylesheet>