rss_converter_twitter.com.xsl: make the feed validate with feedvalidator.org
authorAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 12:10:20 +0000 (13:10 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 12:10:20 +0000 (13:10 +0100)
Make the Twitter feed validate with http://feedvalidator.org and also
improve compatibility by providing a guid and by excluding the weird
xmlns:php namespace in the output.

rss_converter_twitter.com.xsl

index a5f3c4b..76937e4 100644 (file)
@@ -21,7 +21,8 @@
 <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl"
-    xsl:extension-element-prefixes="php">
+    xsl:extension-element-prefixes="php"
+    exclude-result-prefixes="php">
 
     <xsl:param name="generateEnclosure"/>
 
     <xsl:template match="//*[@data-item-type='tweet']">
         <xsl:variable name="user-name" select=".//div[contains(@class, 'js-stream-tweet')]/@data-screen-name"/>
         <xsl:variable name="tweet-text" select=".//p[contains(@class, 'js-tweet-text')]"/>
+        <xsl:variable name="tweet-permalink" select="concat($twitterBaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/>
         <item>
             <title>
                 <xsl:value-of select="concat($user-name, ': ', $tweet-text)"/>
             </title>
             <link>
-                <xsl:value-of select="concat($twitterBaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/>
+                <xsl:value-of select="$tweet-permalink"/>
             </link>
+            <guid>
+                <xsl:value-of select="$tweet-permalink"/>
+            </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select=".//span[contains(@class, 'js-short-timestamp')]/@data-time"/>
                 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
     </xsl:template>
 
     <xsl:template match="/">
+        <xsl:variable name="channel-title" select="concat('Twitter / ', $screen-name)"/>
+        <xsl:variable name="channel-link" select="//link[@rel='canonical']/@href"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$twitterBaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
-                    <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/>
+                    <xsl:value-of select="$channel-title"/>
                 </title>
                 <link>
-                    <xsl:value-of select="//link[@rel='canonical']/@href"/>
+                    <xsl:value-of select="$channel-link"/>
                 </link>
                 <description>
                     <xsl:value-of select="//meta[@name='description']/@content"/>
                 </description>
                 <image>
+                    <title>
+                        <xsl:value-of select="$channel-title"/>
+                    </title>
+                    <link>
+                        <xsl:value-of select="$channel-link"/>
+                    </link>
                     <url>
                         <xsl:value-of select="//a[contains(@class, 'profile-picture media-thumbnail')]/@href"/>
                     </url>