rss_converter_pump.io.xsl: make the feed validate with feedvalidator.org
authorAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 14:05:13 +0000 (15:05 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 14:05:13 +0000 (15:05 +0100)
Make the pump.io 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_pump.io.xsl

index 94b083b..ed99713 100644 (file)
@@ -22,7 +22,8 @@
 <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl"
 <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:output method="xml" indent="yes"/>
 
 
     <xsl:output method="xml" indent="yes"/>
 
     <xsl:variable name="user-name" select="substring-after(//div[@id='profile-block']/@data-profile-id, ':')"/>
 
     <xsl:template match="//div[@id='user-content-activities']//ul[@id='major-stream']/li">
     <xsl:variable name="user-name" select="substring-after(//div[@id='profile-block']/@data-profile-id, ':')"/>
 
     <xsl:template match="//div[@id='user-content-activities']//ul[@id='major-stream']/li">
-        <xsl:variable name="activity-text" select=".//div[@class='activity-content']"/>
+        <xsl:variable name="item-content" select=".//div[@class='activity-content']"/>
+        <xsl:variable name="item-permalink" select=".//p[@class='muted']/small/a/@href"/>
         <item>
             <title>
         <item>
             <title>
-                <xsl:value-of select="concat($user-name, ': ', normalize-space($activity-text))"/>
+                <xsl:value-of select="concat($user-name, ': ', normalize-space($item-content))"/>
             </title>
             <link>
             </title>
             <link>
-                <xsl:value-of select=".//p[@class='muted']/small/a/@href"/>
+                <xsl:value-of select="$item-permalink"/>
             </link>
             </link>
+            <guid>
+                <xsl:value-of select="$item-permalink"/>
+            </guid>
             <pubDate>
                 <xsl:value-of select="php:functionString('Tweeper::str_to_gmdate', .//abbr[@class='easydate']/@title)"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
             <pubDate>
                 <xsl:value-of select="php:functionString('Tweeper::str_to_gmdate', .//abbr[@class='easydate']/@title)"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
-                <xsl:copy-of select="$activity-text/node()"/>
+                <xsl:copy-of select="$item-content/node()"/>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>
     </xsl:template>
 
     <xsl:template match="/">
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>
     </xsl:template>
 
     <xsl:template match="/">
+        <xsl:variable name="channel-title" select="concat(substring-after($user-name, '@'), ' / ', substring-before($user-name, '@'))"/>
+        <xsl:variable name="channel-link" select="concat('https://', substring-after($user-name, '@'), '/', substring-before($user-name, '@'))"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
-                    <xsl:value-of select="concat(substring-after($user-name, '@'), ' / ', substring-before($user-name, '@'))"/>
+                    <xsl:value-of select="$channel-title"/>
                 </title>
                 <link>
                 </title>
                 <link>
-                    <xsl:value-of select="concat('https://', substring-after($user-name, '@'), '/', substring-before($user-name, '@'))"/>
+                    <xsl:value-of select="$channel-link"/>
                 </link>
                 <description>
                     <xsl:value-of select="normalize-space(//h1[@class='media-header'])"/>
                 </description>
                 <image>
                 </link>
                 <description>
                     <xsl:value-of select="normalize-space(//h1[@class='media-header'])"/>
                 </description>
                 <image>
+                    <title>
+                        <xsl:value-of select="$channel-title"/>
+                    </title>
+                    <link>
+                        <xsl:value-of select="$channel-link"/>
+                    </link>
                     <url>
                         <xsl:value-of select="//div[@id='profile-block']/span/img[@class='img-rounded media-object']/@src"/>
                     </url>
                     <url>
                         <xsl:value-of select="//div[@id='profile-block']/span/img[@class='img-rounded media-object']/@src"/>
                     </url>