Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dividing rss list into 2 coloums with xsl

Status
Not open for further replies.

owen88

Programmer
Apr 24, 2008
5
hi there,
i have an rss feed that i would like to split into 2 coloums 5 news items on each side. im currently using the default dot net nuke style sheet which is as follows;

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html" indent="yes"/>
<xsl:param name="TITLE"/>

<xsl:template match="rss">
<!-- Do not show channel image -->
<xsl:for-each select="channel/item">
<br>

<strong><a href="{link}" target="_main"><xsl:value-of select="title"/></a></strong><br></br>

<!-- only display markup for description if it's present -->
<xsl:value-of select="description"/>

</br>
<br></br>
</xsl:for-each>
</xsl:template>

<xsl:template match="description">
<br>
<xsl:value-of select="."/>
</br>
</xsl:template>

</xsl:stylesheet>




thanks for the help :)
 
[0] What a thread that we had worked together, k5tm! Must have both had been in very good form to inspire that kind of answers. Going through it makes me feel even my handle like a 3rd person.

[1] The question raised here is of simpler nature. Besides, I would have some comments on it pertinent to the script shown.
[1.1] There is nothing of the kind as non-empty <br></br>. It is not html. So you have to rewrite it.
[1.2] Do you know the template matching "description" actually is dummy and never being called?

[2] This is how you get the desired result. The script also implicitly show how description template is made good use of.
[tt]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[ignore][/ignore]">
<xsl:eek:utput method="html" indent="yes"/>
<xsl:param name="TITLE"/>

<xsl:template match="/">
<html>
<body>
<!-- note: Since the border is "0", one wouldn't see the case when there is no node to fill the right-hand-side td; else, you have check its presence. If it is absent, put &nbsp; there to make table look normal -->
<table border="0">
<xsl:apply-templates select="rss" />
</table>
</body>
</html>
</xsl:template>

<xsl:template match="rss">
<!-- Do not show channel image -->
<xsl:for-each select="channel/item[position() mod 2 = 1]">
<tr>
<td>
<strong><a href="{link}" target="_main"><xsl:value-of select="title"/></a></strong><br />
<!-- only display markup for description if it's present -->
<xsl:apply-templates select="description" />
</td>
<td>
<strong><a href="{following-sibling::item[1]/link}" target="_main">
<xsl:value-of select="following-sibling::item[1]/title"/></a></strong><br />
<!-- only display markup for description if it's present -->
<xsl:apply-templates select="following-sibling::item[1]/description" />
</td>
</tr>
</xsl:for-each>
</xsl:template>

<xsl:template match="description">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top