In a previous post, I showed the XSL transform I designed to transform a simple XML file I use into “(almost) valid RSS.” I called it (almost) valid because of one problem, which I address here.
The problem reviewed
My original XSL assigned an arbitrary ID to each entry in the news file based on its order in the list. What this meant was that the first item received the integer 1 for an ID, the second 2, the third 3, etc. Here it is:
<!--old method, produces invalid link & guid--> <link><xsl:text>http://www.duncanandmeg.org/news.php#</xsl:text> <xsl:value-of select="position()" /></link> <guid><xsl:text>http://www.duncanandmeg.org/news.php#</xsl:text> <xsl:value-of select="position()" /></guid>
This was fine for my original purposes, but since this hardly represented a unique & permanent identifier for each post, it caused some problems when echoed into the RSS <guid> and <link> elements. The significance of the <guid> element in particular is eliminated with such an approach. Every time I added an item to the list (see the previous post for an explanation of my schema), it would be assigned the ID of 1, and the older posts would be assigned the ID numbers 2, 3, 4, 5 etc.
This meant that most RSS aggregators would not detect that a new post had appeared and would not update accordingly.
Continue reading ‘Producing valid RSS from my XSL Transform’