如何在有条件选择的情况下实现表格中行的颜色交替?
xml文档:
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="program.xsl"?>
<root>
<programme>
<id>47852</id>
<name>中国</name>
<chnid>1001</chnid>
</programme>
<programme>
<id>47856</id>
<name>俯视</name>
<chnid>1003</chnid>
</programme>
<programme>
<id>47854</id>
<name>科学</name>
<chnid>1002</chnid>
</programme>
<programme>
<id>47853</id>
<name>天天饮食</name>
<chnid>1001</chnid>
</programme>
</root>
xsl文档:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="chanid" select="1001" />
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>id</th>
<th>name</th>
<th>channelid</th>
</tr>
<tr><td><xsl:value-of select="$chanid"/></td>
</tr>
<xsl:for-each select="root/programme">
<xsl:if test="chnid='1001'">
<tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="position()"/><xsl:value-of select="name"/></td>
<td><xsl:value-of select="chnid"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
由于是条件选择,position()返回的是原来xml中结点的位置,我想获得条件选择后的结点位置,我试过用变量,后来发现xsl中的变量是不能修改的,请问我该如何实现这个功能?能不能详细说下,谢谢!!