用于Atom转换成rss的xslt文件
作为一个blogger.com的用户,我一直很遗憾blogger.com没有给用户提供rss功能,有人说没有rss的blog不是blog,虽然夸张了一点,但是也表现出来rss对blog的重要性。
去年12月份的时候blogger.com一反常态,在Atom标准推出没有几天以后,马上提供了Atom功能,可是市面上的新闻阅读器基本上都不支持Atom,按照blogger.com的说明只有4种新闻阅读器支持Atom,我经常使用的FeedDemon至今好像也没有提供Atom的支持,于是,想起来毛主席的“自己动手丰衣足食”的教导了,于是我用Xslt写了一个Atom和Rss的转换,经过试验,至少可以在FeedDemon,Sharpreader下面使用,因为时间关系,我没有打算让这个转换完全符合Rss2.0标准,实际上除了工作量以外,实现这个标准应该是没有难度的。
因为没有合适的测试环境,我只保证这个文件支持blogger.com提供的Atom转换成Rss,而且只保证在FeedDemon,Sharpreader下面使用是完全正常的。
代码如下:
<?xml version="1.0" encoding="GB2312" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" > <xsl:output encoding="GB2312" /> <xsl:template match="/"> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"> <channel> <xsl:apply-templates select="atom:feed" /> </channel> </rss>
</xsl:template>
<xsl:template match="atom:feed">
<title> <xsl:value-of select="atom:title" /> </title>
<link> <xsl:for-each select="atom:link"> <xsl:if test="@rel='alternate'"> <xsl:value-of select="@href" /> </xsl:if> </xsl:for-each> </link>
<description> <xsl:value-of select="atom:tagline" /> </description>
<generator>Tinydust Studio Atom2Rss tool by Tinyfool</generator>
<xsl:apply-templates select="atom:entry" />
</xsl:template>
<xsl:template match="atom:entry">
<item> <dc:creator> <xsl:value-of select="atom:author/atom:name" /> </dc:creator> <title> <xsl:value-of select="atom:title" /> </title> <link> <xsl:for-each select="atom:link"> <xsl:if test="@rel='alternate'"> <xsl:value-of select="@href" /> </xsl:if> </xsl:for-each> </link> <pubDate> <xsl:value-of select="atom:modified" /> </pubDate> <guid> <xsl:value-of select="atom:id" /> </guid> <description> <xsl:value-of select="atom:content" /> <xsl:value-of select="atom:summary" /> </description> </item> </xsl:template> </xsl:stylesheet>
具体使用的时候,我是做了一个asp文件调用Dom进行服务器端的Xslt转换。 相关文件可以Mail向我索取... [email protected] 
|