OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
[XSL] incrementing a variable in a for-each
This page's ID:
10910
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Hello there, I have to split an XML in two parts and exclude some entries according to an attribute. The first part must feature the first six visible entries.[code]<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1"/> <xsl:template match="root"> <xsl:variable name="entriesVisible" select="0" /> <xsl:variable name="entriesDone" select="0" /> <table border="1"> <tr><xsl:for-each select="entry"> <td> entriesVisible = <xsl:value-of select="$entriesVisible" /><br /> entriesDone = <xsl:value-of select="$entriesDone" /><br /> <xsl:if test="$entriesVisible < 6"> <xsl:if test="@tem_id != 6 and @tem_id != 7"> <xsl:variable name="entriesVisible" select="1+$entriesVisible" /> <!-- should be increased --> <xsl:call-template name="1stPassEntries" /> </xsl:if> </xsl:if> <xsl:variable name="entriesDone" select="$entriesDone + 1" /> <!-- should be increased --> </td></xsl:for-each> </tr> </table> <hr /><!-- separator --> <table border="1"> <tr><xsl:for-each select="entry"> <td> entriesVisible = <xsl:value-of select="$entriesVisible" /><br /> entriesDone = <xsl:value-of select="$entriesDone" /><br /> <xsl:if test="position() > $entriesVisible"> <xsl:if test="@tem_id != 6 and @tem_id != 7"> <xsl:variable name="entriesVisible" select="1+$entriesVisible" /> <!-- should be increased --> <xsl:call-template name="1stPassEntries" /> </xsl:if> </xsl:if> <xsl:variable name="entriesDone" select="$entriesDone + 1" /> <!-- should be increased --> </td></xsl:for-each> </tr> </table> </xsl:template> <xsl:template name="1stPassEntries"> <b><xsl:value-of select="@name" /></b> </xsl:template> </xsl:stylesheet>[/code] sorry for the length of that XSL. With the code above, the variables [i]entriesVisible[/i] and [i]entriesDone[/i] are stuck at zero. And when I put the first declaration of theses variables right below the [i]<xsl:template match="root">[/i], SABLOTRON screams [b]Warning: Sablotron error on line 1976: conflicting variable bindings 'entriesVisible'[/b] >__< Thanks in advance. [b]Mathieu "POÏ" HENRI[/b] [This message has been edited by poi (edited 02-17-2003).]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »