Modularisierung des ATOM-XSL

mode="escaped" für RSS-XSL
Links zu Newsseiten in den Feeds


git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@325 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
astro 2006-05-24 02:49:51 +00:00
parent bb29db45ad
commit b907457c75
2 changed files with 42 additions and 26 deletions

View File

@ -3,7 +3,7 @@
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">
exclude-result-prefixes="xsl crypto date">
<xsl:include href="common.xsl" />
@ -28,25 +28,34 @@
<pubDate><xsl:value-of select="news/item/@date"/></pubDate>
-->
<xsl:for-each select="document(newsfile)/item">
<xsl:sort select="date:seconds(@date)" data-type="number" order="descending" />
<entry>
<id><xsl:value-of select="crypto:sha1(concat(@title,@date))"/></id>
<title><xsl:value-of select="@title"/></title>
<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>
</entry>
<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="https://www.c3d2.de/{substring-before($newsfile, '.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>
</entry>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl date">
<xsl:output method="xml"
version="1.0"
@ -18,9 +19,13 @@
<link>https://www.c3d2.de/</link>
<description>Neues aus dem Chaos Computer Club Dresden</description>
<language>de-de</language>
<pubDate><xsl:value-of select="news/item/@date"/></pubDate>
<!-- TODO: Insert "now": <pubDate><xsl:value-of select="news/item/@date"/></pubDate> -->
<xsl:for-each select="newsfile">
<xsl:apply-templates select="document(current())/item" />
<xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" />
<xsl:apply-templates select="document(.)/item">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:for-each>
</channel>
@ -28,28 +33,30 @@
</xsl:template>
<xsl:template match="item">
<xsl:param name="newsfile"/>
<item>
<title><xsl:value-of select="@title"/></title>
<description><xsl:apply-templates/></description>
<link>https://www.c3d2.de/<xsl:value-of select="substring-before($newsfile, '.xml')"/>.html</link>
<description><xsl:apply-templates mode="escaped"/></description>
<author><xsl:value-of select="@author"/></author>
<category><xsl:value-of select="@category"/></category>
<pubDate><xsl:value-of select="@date"/></pubDate>
</item>
</xsl:template>
<xsl:template match="pre">
<xsl:template match="pre" mode="escaped">
&lt;pre&gt;<xsl:apply-templates/>&lt;/pre&gt;
</xsl:template>
<xsl:template match="p">
<xsl:template match="p" mode="escaped">
&lt;p&gt;<xsl:apply-templates/>&lt;/p&gt;
</xsl:template>
<xsl:template match="image">
<xsl:template match="image" mode="escaped">
&lt;img src="<xsl:value-of select="."/>"<xsl:if test="@title"> title="<xsl:value-of select="@title"/>" alt="<xsl:value-of select="@title"/>"</xsl:if><xsl:if test="@class"> class="<xsl:value-of select="@class"/>"</xsl:if>/&gt;
</xsl:template>
<xsl:template match="link">
<xsl:template match="link" mode="escaped">
&lt;a<xsl:choose>
<xsl:when test="@href">
href="<xsl:value-of select="@href"/>"