rss_converter_*.xsl: specify xml:base
authorAntonio Ospite <ao2@ao2.it>
Sat, 22 Feb 2014 08:52:38 +0000 (09:52 +0100)
committerAntonio Ospite <ao2@ao2.it>
Thu, 24 Apr 2014 08:17:14 +0000 (10:17 +0200)
Some feed readers expand relative URLs in items by extracting the base
URL from the enclosing <link/> element, however this is not a globally
accepted practice.

Specifying xml:base is useful to cover other ways in which relative URLs
are expanded, see:
  https://cyber.law.harvard.edu/rss/relativeURI.html
  http://www.w3.org/TR/xmlbase/#resolution

rss_converter_dilbert.com.xsl
rss_converter_pump.io.xsl
rss_converter_twitter.com.xsl

index 7394b91..0fb28fc 100644 (file)
@@ -65,6 +65,7 @@
     <xsl:template match="/">
 
         <rss version="2.0">
     <xsl:template match="/">
 
         <rss version="2.0">
+            <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
index 6b05d0c..b127f3a 100644 (file)
@@ -26,6 +26,9 @@
 
     <xsl:output method="xml" indent="yes"/>
 
 
     <xsl:output method="xml" indent="yes"/>
 
+    <xsl:variable name="domain-name" select="substring-after(//div[@id='profile-block']/@data-profile-id, '@')"/>
+    <xsl:variable name="BaseURL" select="concat('https://', $domain-name)"/>
+
     <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">
@@ -52,6 +55,7 @@
     <xsl:template match="/">
 
         <rss version="2.0">
     <xsl:template match="/">
 
         <rss version="2.0">
+            <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
index 09ba933..3184044 100644 (file)
@@ -65,6 +65,7 @@
     <xsl:template match="/">
 
         <rss version="2.0">
     <xsl:template match="/">
 
         <rss version="2.0">
+            <xsl:attribute name="xml:base"><xsl:value-of select="$twitterBaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
             <channel>
                 <generator>Tweeper</generator>
                 <title>