I try to format a RSS feed from my DNN site and make it look nice. I would like to show the content in 4 columns:
https://dl.dropbox.com/u/38410375/liste.png
I need a XSL file to use in DNN XML module, but can not get it work. I am not sure the code I already have makes sense but thats what I have found so far online. I hope somebody here can push me in the right direction as the error message I get is pretty cryptic for me.
Thank you in advance for your attention!
Here what I have:
<?xml-stylesheet type="text/xsl" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="ItemsToShow"/>
<xsl:param name="ShowItemDetails"/>
<xsl:param name="ShowItemDate"/>
<xsl:param name="Locale"/>
<xsl:template match="rss">
<table>
<xsl:for-each select="channel/item[position()=$ItemsToShow or $ItemsToShow]"/>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">
<xsl:if test="$ShowItemDate='true'">
<xsl:value-of select="pubDate"/>
</xsl:if>
<xsl:if test="$ShowItemDate='true'">
<xsl:text>
-
</xsl:text>
</xsl:if>
</div>
<div class="DNN_News_ItemLink">
<a href="{link}" target="_blank">
<xsl:value-of select="title"/>
</a>
</div>
<xsl:if test="$ShowItemDetails='true'">
<div class="DNN_News_ItemDetails">
<a href="{link}" target="_blank">
<xsl:value-of select="description" disable-output-escaping="yes"/>
</a>
</div>
</xsl:if>
</div>
</table>
</xsl:template>
<xsl:template match="rss" mode="tr">
<tr>
<xsl:apply-templates select="." mode="td"/>
<xsl:apply-templates select="following-sibling::*[position() < 4]" mode="td"/>
</tr>
<xsl:apply-templates select="following-sibling::*[4]" mode="tr"/>
</xsl:template>
<xsl:template match="rss" mode="td">
<td>
<xsl:apply-templates select="text()"/>
</td>
</xsl:template>
Is something like this what you're going for?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="ItemsToShow" select="5"/>
<xsl:param name="ShowItemDetails" select="'true'"/>
<xsl:param name="ShowItemDate"/>
<xsl:param name="Locale"/>
<xsl:template match="rss">
<table>
<xsl:apply-templates select="channel/item[position() <= $ItemsToShow or
not($ItemsToShow)]
[position() mod 4 = 1]"
mode="row"/>
</table>
</xsl:template>
<xsl:template match="item" mode="row">
<tr>
<xsl:apply-templates select=". | following-sibling::item[position() < 4]"
mode="cell"/>
</tr>
</xsl:template>
<xsl:template match="item" mode="cell">
<td>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">
<xsl:apply-templates select="pubDate[$ShowItemDate='true']" />
<xsl:apply-templates select="pubDate[not($ShowItemDate='true')]"
mode="noDate" />
</div>
<div class="DNN_News_ItemLink">
<a href="{link}" target="_blank">
<xsl:value-of select="title"/>
</a>
</div>
<xsl:apply-templates select="self::node()[$ShowItemDetails = 'true']"
mode="details" />
</div>
</td>
</xsl:template>
<xsl:template match="item" mode="details">
<div class="DNN_News_ItemDetails">
<a href="{link}" target="_blank">
<xsl:value-of select="description" disable-output-escaping="yes" />
</a>
</div>
</xsl:template>
<xsl:template match="pubDate" mode="noDate">
<xsl:text>-</xsl:text>
</xsl:template>
</xsl:stylesheet>
When run on that RSS feed's XML, the result is:
<table>
<tr>
<td>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">-</div>
<div class="DNN_News_ItemLink"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=2" target="_blank">Historias Sem Data</a></div>
<div class="DNN_News_ItemDetails"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=2" target="_blank">
<img alt="" src="http://literatura24.com/Portals/4/ebooks-pictures/machado_de_assis-historias_sem_data.jpg" style="margin-right: 5px;" align="left" width="100" height="166" />Autor: Assis, Machado de, 1839-1908<br />
Título: Historias Sem Data<br />
Idioma: Português<br />
Assunto:<br />
Disponível como: EPUB e KINDLE
</a></div>
</div>
</td>
<td>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">-</div>
<div class="DNN_News_ItemLink"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=1" target="_blank">Os LusÃadas</a></div>
<div class="DNN_News_ItemDetails"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=1" target="_blank">
<p><img alt="" src="http://literatura24.com/Portals/4/ebooks-pictures/220px-Os_Lus%C3%ADadas.jpg" style="margin-right: 5px;" align="left" width="100" height="156" />Autor: Camões, Luís Vaz de, 1524-1580<br />
Título: Os Lusíadas<br />
Idioma: Português<br />
Assunto: poesia Português<br />
Disponível como: EPUB e KINDLE<br />
<br />
</p>
</a></div>
</div>
</td>
<td>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">-</div>
<div class="DNN_News_ItemLink"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=4" target="_blank">The Adventures of Sherlock Holmes</a></div>
<div class="DNN_News_ItemDetails"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=4" target="_blank">
<img alt="" src="http://literatura24.com/Portals/4/ebooks-pictures/399365_Memoirs-of-Sherlock-Holmes-book-jacket.jpg" height="150" align="left" width="100" />Autor: Doyle, Arthur Conan, Sir, 1859-1930<br />
Título: The Adventures of Sherlock Holmes<br />
Idioma: Inglês<br />
Assunto: detetive e mistério<br />
Disponível como: EPUB e KINDLE
</a></div>
</div>
</td>
<td>
<div class="DNN_News_Item">
<div class="DNN_News_ItemDate">-</div>
<div class="DNN_News_ItemLink"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=3" target="_blank">Viagens na Minha Terra</a></div>
<div class="DNN_News_ItemDetails"><a href="http://literatura24.com/Default.aspx?tabid=436&fileshareact=viewfile&Fileid=3" target="_blank">
<img alt="" src="http://literatura24.com/Portals/4/ebooks-pictures/41606_500.jpg" style="margin-right: 5px;" align="left" width="100" height="139" />Autor: Almeida Garrett, João Batista da Silva Leitão de, Visconde de, 1799-1854<br />
Título: Viagens na Minha Terra (Completo)<br />
Idioma: Português<br />
Assunto: ficção Português<br />
Disponível como: EPUB e KINDLE
</a></div>
</div>
</td>
</tr>
</table>