943,758 Members | Top Members by Rank

Ad:
Sep 24th, 2008
0

XSLT Loop - I'm Stuck!!

Expand Post »
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
Last edited by madigital; Sep 24th, 2008 at 10:01 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
madigital is offline Offline
5 posts
since Sep 2008
Sep 26th, 2008
0

Re: XSLT Loop - I'm Stuck!!

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.
Reputation Points: 21
Solved Threads: 2
Newbie Poster
miepmuts is offline Offline
14 posts
since Aug 2008
Dec 29th, 2008
0

Re: XSLT Loop - I'm Stuck!!

Click to Expand / Collapse  Quote originally posted by miepmuts ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mlohokare is offline Offline
22 posts
since Oct 2008
Jan 2nd, 2009
0

Re: XSLT Loop - I'm Stuck!!

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.
Reputation Points: 22
Solved Threads: 11
Junior Poster
fpmurphy is offline Offline
144 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in XML, XSLT and XPATH Forum Timeline: Newbie: XPath Axis
Next Thread in XML, XSLT and XPATH Forum Timeline: Split Table in XSLT





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC