分頁使用中遇到幾個問題
WD-xsl版本中和
版本中遇到的問題
wd-xsl版本支持expr 但Transform不支持此功能
Transform支持
在WD-xsl版本中 將要改爲
[code]<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html><head>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<xsl:comment>
<![CDATA[
var OnePageNum=2;
var PageNum=1;
var XMLPageNum=1;
function pages(Num)
{
stylesheet=document.XSLDocument;
source=document.XMLDocument;
nodes=source.documentElement.childNodes;
len=nodes.length;
for(i=1;i<(len/OnePageNum);i++); //有做修改
XMLPageNum=i;
var firstNum=0;
var lastNume=0;
if (Num=="first") {PageNum=1;}
if (Num=="previous") {if (PageNum>1) PageNum -=1;}
if (Num=="next") {if (PageNum<XMLPageNum) PageNum +=1;}
if (Num=="last") {PageNum =XMLPageNum;}
sortField=document.XSLDocument.selectSingleNode("//@expr");
firstNum=OnePageNum*(PageNum-1)+1;
lastNum=OnePageNum*(PageNum-1)+OnePageNum;
text="childnumber(this)>="+firstNum+" & childnumber(this)<="+lastNum;
sortField.value=text;
data.innerHTML=source.documentElement.transformNode(stylesheet);
}
]]>
</xsl:comment>
</SCRIPT>
<STYLE>
.Teamnamea{width:150px;font-weight:bold;color:red;padding:2px;}
.Teamnameb{width:150px;font-weight:bold;color:green;padding:2px;}
.Teamlet{width:35px;font-weight:bold;}
.odd {background:#ededed;}
a#Tzd {position:relative;color:red;left:0px; font-weight:bold;text-decoration:none;}
a#Tzd:link,a#tip:hover {text-decoration:none;color:#000;display:block}
a#Tzd:visited {color:#000;text-decoration:none;color:red;}
a#Tzd span {display:none;text-decoration:none;}
a#Tzd:hover #TzdMSG {display:block;border:1px solid #F99;background:#FFEFEF;padding:3px 3px;position:absolute;top:0px;left:25px;color:#009933}
.keybutton { cursor:hand; font-size: 12px; color: #003300; background: #ffffff; border: 0px solid;}
</STYLE>
<div id="data" width="553">
<xsl:apply-templates select="league"/>
</div>
<table align="center" width="500" >
<tr>
<td>
<button id="cmdfirstPage" class="keybutton" onclick="pages('first');" >首页</button>
<button id="cmdpreviousPage" class="keybutton" onclick="pages('previous');" >上一页</button>
<button id="cmdnextPage" class="keybutton" onclick="pages('next');">下一页</button>
<button id="cmdlastPage" class="keybutton" onclick="pages('last');">尾页</button>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="league">
<TABLE style="FONT-SIZE: 12px; PADDING-TOP: 3px" cellSpacing="1" cellPadding="0" width="553" bgColor="#ffffff" border="0">
<TBODY>
<TR>
<TD width="97" height="22" align="center" bgColor="#cccccc">開賽時間</TD>
<TD align="center" width="150" bgColor="#cccccc">比賽隊伍</TD>
<TD align="center" width="85" bgColor="#cccccc">讓球</TD>
<TD align="center" width="85" bgColor="#cccccc">大小</TD>
<TD align="center" width="90" bgColor="#cccccc">独赢</TD>
<TD align="center" width="81" bgColor="#cccccc">單雙</TD>
</TR>
<xsl:apply-templates select="union" />
</TBODY>
</TABLE>
</xsl:template>
<xsl:template match="union">
<xsl:if expr="childnumber(this)>=1 & childnumber(this)<=2 ">
<tr align="middle" style="COLOR: #FFFFFF; PADDING-TOP: 3px;background:green;">
<td colspan="6" align="center"><b><xsl:value-of select="@Name"/></b></td>
</tr>
<xsl:apply-templates select="Team" />
</xsl:if>
</xsl:template>
<xsl:template match="Team">
<TR align="middle" class="odd">
<TD width="97" rowspan="3" align="center">
<span class="Teamtime">2006-02-05</span><br/>
<span><xsl:if test='.[@GunQiu$eq$1]'><a href="javascript:void(0);" id="Tzd">zd<span id="TzdMSG">zd</span>
</a></xsl:if></span>
</TD>
<TD width="96" rowspan="2" align="center">
<span class="Teamnamea"><xsl:value-of select="@TeamA"/>(主)</span>
<br/>
<span class="Teamnameb"><xsl:value-of select="@TeamB"/></span>
</TD>
<TD height="20" align="center">
<span class="Teamlet"> 5 </span>
<span class="Teamlet"> 0.96 </span>
</TD>
<TD height="20" align="center">
<span class="Teamlet">大9 </span>
<span class="Teamlet"> 0.96</span>
</TD>
<TD height="20" align="center">
<span>0.96 </span>
</TD>
<TD height="20" align="center">
<span>0.93</span>
</TD>
</TR>
<TR align="middle" class="odd">
<TD height="20" align="center">
<span class="Teamlet"></span>
<span class="Teamlet">0.96 </span>
</TD>
<TD height="20" align="center">
<span class="Teamlet"> </span>
<span class="Teamlet">0.96</span>
</TD>
<TD height="20" align="center">
<span>0.96 </span>
</TD>
<TD height="20" align="center">
<span>0.93 </span>
</TD>
</TR>
<TR align="middle" class="odd">
<TD width="96" align="center">
<span style="color:blue;font-weight:bold;padding-left:25px;">和局</span>
</TD>
<TD height="20" align="center"></TD>
<TD height="20" align="center"></TD>
<TD height="20" align="center"><span>0.96 </span></TD>
<TD height="20" align="center"><span></span></TD>
</TR>
<!-- <xsl:value-of select="@GunQiu"/>
<xsl:value-of select="@UnionID"/>
<xsl:value-of select="@TeamA"/>
<xsl:value-of select="@TeamB"/>
<xsl:value-of select="@TeamAID"/>
<xsl:value-of select="@TeamBID"/>
<xsl:value-of select="@CloseTime"/> -->
</xsl:template>
</xsl:stylesheet>[/code]