XSLT Loop - I'm Stuck!!

Please support our XML, XSLT and XPATH advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 5
Reputation: madigital is an unknown quantity at this point 
Solved Threads: 0
madigital madigital is offline Offline
Newbie Poster

XSLT Loop - I'm Stuck!!

 
0
  #1
Sep 24th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 14
Reputation: miepmuts is an unknown quantity at this point 
Solved Threads: 2
miepmuts miepmuts is offline Offline
Newbie Poster

Re: XSLT Loop - I'm Stuck!!

 
0
  #2
Sep 26th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 22
Reputation: mlohokare is an unknown quantity at this point 
Solved Threads: 0
mlohokare mlohokare is offline Offline
Newbie Poster

Re: XSLT Loop - I'm Stuck!!

 
0
  #3
Dec 29th, 2008
Originally Posted by miepmuts View Post
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 101
Reputation: fpmurphy is an unknown quantity at this point 
Solved Threads: 5
fpmurphy fpmurphy is offline Offline
Junior Poster

Re: XSLT Loop - I'm Stuck!!

 
0
  #4
Jan 2nd, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the XML, XSLT and XPATH Forum


Views: 1916 | Replies: 3
Thread Tools Search this Thread



Tag cloud for XML, XSLT and XPATH
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC