这是你想要的吗?
<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>
在该 RSS 提要的 XML 上运行时,结果是:
<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>