多行数据排序(序号)的问题!

我的xml和xsl文件如下:
查询.xml:

 1<cd>   
 2&lt;查询&gt;   
 3<number>12</number>
 4<code>
 5<dataset>
 6<define>
 7<fields>
 8<mphonecode></mphonecode>
 9</fields>
10</define>
11<data>
12<row tcode="888"></row>
13<row tcode="000"></row>
14<row tcode="555"></row>
15</data>
16</dataset>
17</code>
18<!--查询-->
19</cd>

查询.xsl:

 1<xsl:stylesheet result-ns="" xmlns="http://www.w3.org/TR/REC-html40" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 2<xsl:template><xsl:apply-templates></xsl:apply-templates></xsl:template>
 3<xsl:template match="/">
 4<html>
 5<head>
 6<title>查询</title>
 7</head>
 8<body>
 9<xsl:apply-templates select="CD/查询"></xsl:apply-templates>
10</body>
11</html>
12</xsl:template>
13<xsl:template match="查询">
14<form action="" method="post" name="form1">
15<p></p>
16<table align="center" border="0" cellspacing="0" width="96%">
17<tr>
18<td height="550">
19<table align="center" border="0" bordercolor="#EEF4FA" cellpadding="0" cellspacing="0" height="545" width="100%">
20<tr>
21<td bgcolor="#E1EBF4" height="30">
22<table align="center" border="0" cellpadding="0" cellspacing="0" height="21" width="99%">
23<tr>
24<td height="21" width="10%"><font face="宋体" size="2">号码</font></td>
25<td width="22%"><table border="0" cellpadding="0" cellspacing="0" height="18" width="69%">
26<tr>
27<td><font face="宋体" size="2"></font><input name="NUMBER" type="text"/></td>
28</tr>
29</table></td>
30<td width="32%"><table border="0" cellpadding="0" cellspacing="0" height="18" width="99%">
31<tr>
32<td width="57%"><table border="0" cellpadding="0" cellspacing="0" width="20%">
33<tr>
34<td><input name="Submit" style="width:60" type="submit" value="查询"/></td>
35</tr>
36</table></td>
37</tr>
38</table></td>
39</tr>
40</table></td>
41</tr>
42<tr>
43<td height="20"><hr align="center" size="1"/>
44<table align="left" border="0" cellpadding="0" cellspacing="2" width="32%">
45<tr bgcolor="#C9D7E9">
46<td width="53"><div align="center"><font face="宋体" size="2">序号</font></div> </td>
47<td height="16" width="193"><div align="left"></div>
48<div align="center"><font face="宋体" size="2">号码</font></div></td>
49</tr>
50<xsl:for-each order-by="@TCODE; +@TCODE" select="CODE/DATASET/DATA/ROW">
51<tr>
52<td align="center" bgcolor="#F5F5F5" width="53"><xsl:eval>formatIndex(childNumber(this),"1")</xsl:eval></td>
53<td align="center" bgcolor="#F5F5F5" height="16" width="193"><font face="宋体" size="2"><xsl:value-of select="@TCODE"></xsl:value-of></font></td>
54</tr>
55</xsl:for-each>
56</table></td>
57</tr>
58<tr>
59<td height="380"></td>
60</tr>
61</table></td>
62</tr>
63</table>
64</form>
65</xsl:template>
66</xsl:stylesheet>

因为多行数据要按照TCODE排序,但是这样一来,多行序号就乱了,这时,怎样给多行的数据排序呢?
---------------------------------------------------------------

改变序号即可

1<xsl:for-each order-by="@TCODE; +@TCODE" select="CODE/DATASET/DATA/ROW">
2<tr>
3<td align="center" bgcolor="#F5F5F5" width="53"><xsl:eval>formatIndex(childNumber(this),"1")</xsl:eval></td>
4<td align="center" bgcolor="#F5F5F5" height="16" width="193"><font face="宋体" size="2"><xsl:value-of select="@TCODE"></xsl:value-of></font></td>
5</tr>
6</xsl:for-each>

==>

1<xsl:eval>var i=0;</xsl:eval>
1<xsl:for-each order-by="@TCODE; +@TCODE" select="CODE/DATASET/DATA/ROW">
2<tr>
3<td align="center" bgcolor="#F5F5F5" width="53"><xsl:eval>i=i+1; i</xsl:eval></td>
4<td align="center" bgcolor="#F5F5F5" height="16" width="193"><font face="宋体" size="2"><xsl:value-of select="@TCODE"></xsl:value-of></font></td>
5</tr>
6</xsl:for-each>

:_)

Published At
Categories with Web编程
comments powered by Disqus