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>
sorry for the length of that XSL.
With the code above, the variables entriesVisible and entriesDone are stuck at zero. And when I put the first declaration of theses variables right below the <xsl:template match="root">, SABLOTRON screams Warning: Sablotron error on line 1976: conflicting variable bindings 'entriesVisible' >__<
Thanks in advance.
Mathieu "POÏ" HENRI
[This message has been edited by poi (edited 02-17-2003).]