| | |
XSLT Loop - I'm Stuck!!
Please support our XML, XSLT and XPATH advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 5
Reputation:
Solved Threads: 0
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 <= $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
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 <= $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.
•
•
Join Date: Aug 2008
Posts: 14
Reputation:
Solved Threads: 2
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.
•
•
Join Date: Oct 2008
Posts: 22
Reputation:
Solved Threads: 0
•
•
•
•
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.
<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
![]() |
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Newbie: XPath Axis
- Next Thread: Split Table in XSLT
Views: 1916 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for XML, XSLT and XPATH
api blogger blogging code dataset delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss serialization standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





