Hi everyone!

First post here.

I've been programming for years but this xslt confuses the heck out of me.

Can someone please tell me how to get this piece of code to work? It's a fragment reading in an rss feed and I'm trying to get it to only show 5 news items. The test for the 'news' works ok but I can't get the loop to work. I get this error

MM_XSLTransform error:
"e:\Domains\wiiuser.co.uk\wwwroot\rssfrag.xsl" is not a valid XSL document.
XSLT compile error at file:///e:/Domains/wiiuser.co.uk/wwwroot/rssfrag.xsl(51,5). See InnerException for details.

The code is:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>

<xsl:variable name="n-rows" select="5"/>
<xsl:param name="i" select="0"></xsl:param>

<xsl:template match="/">
<link href="includes/main.css" rel="stylesheet" type="text/css" />

<div id="rssfeed1">
<div id="rssheader">
<p class="newsheader">Wii News Provided by Officialnintendomagazine.co.uk</p>
</div>
<xsl:for-each select="rss/channel/item">
<xsl:if test="category='News'">

<xsl:if test="$i &lt;= $n-rows">

<div id="rssitem">
<xsl:variable name="iChange1" select="substring(pubDate,1,16)"/>

<p class="rssdate"><xsl:value-of select="$iChange1"/></p>
<h2 class="rss">
<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</h2>
<p class="bodytext_greyRSS"><xsl:value-of select="description" disable-output-escaping="yes"/></p>
</div>

<xsl:with-param name="i" select="$i + 1"/> [THIS IS THE ERROR LINE 51]
</xsl:if>

</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>

Any help would be appreciated.

Many thanks

I don't know what you intend to do with the <xsl:with-param> but what I understand from the tutorial it is used to pass parameters to a template. So you should call a template before that, or insert a template between the tags.

I don't know what you intend to do with the <xsl:with-param> but what I understand from the tutorial it is used to pass parameters to a template. So you should call a template before that, or insert a template between the tags.

I think for this you have to include
<xsl:call-template name="ABC">
<xsl:with-param......></xsl:with-param>
</xsl:call-template>


and one
<xsl:template name="ABC">
<xsl:param ...... />
............ do what ever you need .........
</xsl:template>

cheers,
Mahesh :)

It is unclear what you are trying to achieve with the code you presented. Frankly, the code is all over the place.

Can you provide a sample of the RSS feed containing at least 5 items that you want to parse and we can then probably help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.