免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
XML創(chuàng)建可排序、分頁(yè)的數(shù)據(jù)顯示頁(yè)面
 

在Web開(kāi)發(fā)中,我們經(jīng)常會(huì)遇到分頁(yè)顯示和排序數(shù)據(jù)記錄集的情況,這在服務(wù)器端使用服務(wù)器端的代碼和數(shù)據(jù)庫(kù)技術(shù)是件很輕松的事情,比如:ASP、PHP、JSP等。然而,如果要在客戶(hù)端顯示多條記錄并且排序是一件很令人頭疼的事情。下面,我們利用Extensible Markup Language(XML,可擴(kuò)展標(biāo)記語(yǔ)言)和Extensible Stylesheet Language Transformations(XSLT,可擴(kuò)展樣式單語(yǔ)言轉(zhuǎn)換),并結(jié)合XML Path Language(XPath,XML路徑語(yǔ)言),只需要編寫(xiě)簡(jiǎn)單的代碼,就可輕松實(shí)現(xiàn)。這種方法避免了與服務(wù)器頻繁打交道的過(guò)程,節(jié)省了數(shù)據(jù)顯示的時(shí)間,瀏覽者無(wú)須等待就可以看到結(jié)果,也可以減少服務(wù)器的負(fù)擔(dān)。另外。由于XML和XSLT技術(shù),使數(shù)據(jù)存儲(chǔ)和數(shù)據(jù)顯示分離,還可以讓我們的代碼能夠重復(fù)利用,大大減輕了程序員編寫(xiě)代碼的負(fù)擔(dān)。 
   下面,我們一步一步地來(lái)實(shí)現(xiàn)我們的功能。 
   
   首先:創(chuàng)建XSLT 
   
   XSLT樣式單的第一行標(biāo)明該XML所遵照的XML規(guī)范版本,然后是標(biāo)明該樣式單使用的名稱(chēng)空間,這里,我們以XSL規(guī)范的正式版本來(lái)進(jìn)行編寫(xiě),而不采用XSL的草案的寫(xiě)法: 
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> 
   注意:兩者在功能和寫(xiě)法上有很大的差異。 
   <?xml version="1.0"?> 
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
   接下來(lái),我們定義XSLT里的模板標(biāo)記: 
   
   <xsl:template match="/"> 
   <xsl:apply-templates select="/客戶(hù)關(guān)系表"/> 
   </xsl:template> 
   
   <xsl:template match="/客戶(hù)關(guān)系表"></xsl:template> 
   
   我們把要顯示的樣式寫(xiě)到模板里面。我們使用HTML的數(shù)據(jù)島來(lái)存放我們的數(shù)據(jù),這些數(shù)據(jù)可以利用SQL Server 2000的XML查詢(xún)來(lái)得到,對(duì)于不支持XML的數(shù)據(jù)庫(kù),我們可以自己編寫(xiě)組件把數(shù)據(jù)轉(zhuǎn)換成XML格式,然后在放到數(shù)據(jù)島里。在HTML里使用數(shù)據(jù)島有兩種方法: 
   一是直接嵌入數(shù)據(jù),如下所示: 
   <XML id=‘‘Data‘‘> 
   <客戶(hù)關(guān)系表> 
   <客戶(hù)>每條數(shù)據(jù)</客戶(hù)> 
   </客戶(hù)關(guān)系表> 
   </XML> 
   二是通過(guò)SRC屬性引用外部文件,如下所示: 
   <XML id=‘‘Data‘‘ src=‘‘Data.xml‘‘></XML> 
   要使用數(shù)據(jù)島里的數(shù)據(jù),必須通過(guò)id名來(lái)引用它,當(dāng)然,由于XSLT文件也是XML格式文件的一種,也可以通過(guò)這種方法來(lái)實(shí)現(xiàn): 
   <XML id=‘‘Style‘‘ src=‘‘Style.xsl‘‘></XML> 
   我們?cè)陧?yè)面中加入標(biāo)記DIV來(lái)顯示我們的轉(zhuǎn)換的結(jié)果: 
   <div id="DisplayArea"></div> 
   使用XSLT轉(zhuǎn)換數(shù)據(jù)島里的數(shù)據(jù),采用DOMDocument的transNode()方法,并把結(jié)果通過(guò)DIV的innerHTML屬性來(lái)展現(xiàn)出來(lái): 
   DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement) 
   
   第二步:實(shí)現(xiàn)客戶(hù)端排序的功能 
   
   我們先設(shè)定一個(gè)默認(rèn)的排序字段,這里選擇“序號(hào)”作為默認(rèn)的排序關(guān)鍵字,并且是按遞增的順序排列,在XSLT里加入sort標(biāo)記: 
   <xsl:for-each select="客戶(hù)"> 
   <xsl:sort select="序號(hào)" order="descending" data-type="number"/> 
   </xsl:for-each> 
   接下來(lái),我們?yōu)闃邮奖碓黾优判虻墓δ?,以便可以響?yīng)用戶(hù)的操作,我們?cè)诒眍^的每個(gè)列上添加onClick事件,該事件調(diào)用sort()函數(shù),允許用戶(hù)通過(guò)單擊該表頭來(lái)進(jìn)行對(duì)該列的排序。 
   <td onClick="sort(‘‘序號(hào)‘‘)">序號(hào)</td> 
   Sort()函數(shù)的語(yǔ)句如下所示: 
   Function Sort(strField) 
   
   Dim sortField 
   Dim sortOrderAttribute 
   
   ‘‘ 得到原來(lái)排序字段的屬性值 
   Set sortField = Style.XMLDocument.selectSingleNode("http://xsl:sort/@select") 
   
   ‘‘ 得到原來(lái)排序的順序?qū)傩灾?nbsp;
   Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("http://xsl:sort/@order") 
   
   ‘‘ 如果我們已經(jīng)按所點(diǎn)擊的列的字段排序,我們必須改變排序的順序; 
   ‘‘ 否則,我們只需要按新所點(diǎn)擊的列字段按默認(rèn)的順序進(jìn)行排序 
   If sortField.Value = strField Or sortField.Value = "./*[0]" Then 
   If sortOrderAttribute.Value = "descending" Then 
   sortOrderAttribute.Value = "ascending" 
   Else 
   sortOrderAttribute.Value = "descending" 
   End If 
   Else 
   sortField.Value = strField 
   sortOrderAttribute.Value = "ascending" 
   End If 
   
   Set sortField = Nothing 
   Set sortOrderAttribute = Nothing 
   ‘‘ 輸出排序后的結(jié)果 
   DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement) 
   
   End Function 
   下面,我們實(shí)現(xiàn)每頁(yè)面顯示的記錄數(shù)和設(shè)定前頁(yè)、后頁(yè)的功能。使用span標(biāo)記顯示目前顯示的是第幾頁(yè)、共多少頁(yè)和記錄的總數(shù)。我們默認(rèn)每頁(yè)顯示6條記錄,用變量intRecordsPerPage保存該值: 
   <table width="100%" border="0" style="font-size:9pt"> 
   <tr> 
   <td align="left"><b>第 <span id="CurrentPage"></span> 頁(yè) 總 <span id="PageCount"></span> 頁(yè)    共有 <span id="RecordCount"></span> 條記錄</b></td> 
   <td align="right"><b>每頁(yè)記錄數(shù):<input onblur="setRecordsPerPage()" id="RecordsPerPage" style="vertical-align:middle;height:15pt;width:30px"/></b></td> 
   <td align="right"> 
   <span id="Paging"> 
   <input type="button" OnClick="FirstPage()" value="第一頁(yè)"/> 
   <input type="button" OnClick="previousPage(1)" value="上一頁(yè)"/> 
   <input type="button" OnClick="nextPage(1)" value="下一頁(yè)"/> 
   <input type="button" OnClick="LastPage()" value="最末頁(yè)"/> 
   </span> 
   </td> 
   </tr> 
   </table> 
   下面以“下一頁(yè)”按鈕執(zhí)行的操作為例子,說(shuō)明轉(zhuǎn)換不同頁(yè)面的處理過(guò)程。該函數(shù)根據(jù)參數(shù)intPage來(lái)決定要顯示的記錄的條數(shù)和相應(yīng)的頁(yè)面,每個(gè)按鈕Value值的變化是通過(guò)動(dòng)態(tài)改變XSL DOM的內(nèi)容來(lái)實(shí)現(xiàn)的: 
   Function nextPage(intPage) 
   
   Dim strDisplay 
   Dim strDateRange 
   
   If CInt(CStr(intPage) * intRecordsPerPage) < _ 
   Data.selectNodes("/客戶(hù)關(guān)系表/客戶(hù)").length Then 
   intPage = CInt(intPage) + 1 
   
   Style.XMLDocument.selectNodes("http://@OnClick") _ 
   (1).Value = "previousPage(" & intPage & ")" 
   
   Style.XMLDocument.selectNodes("http://@OnClick") _ 
   (2).Value = "nextPage(" & intPage & ")" 
   
   Style.XMLDocument.selectNodes _ 
   ("http://xsl:for-each/@select")(1).Value = _ 
   "./客戶(hù)[position() <= " & (CStr(intPage) _ 
   * intRecordsPerPage) & " and position() > " _ 
   & (CInt(intPage) - 1) * intRecordsPerPage & _ 
   "]" 
   
   redisplay (intPage) 
   
   End If 
   
   End Function 
   下面,我們來(lái)看看設(shè)置每個(gè)頁(yè)面記錄條數(shù)的函數(shù)setRecordsPerPage(),該函數(shù)通過(guò)動(dòng)態(tài)修改xsl:for-each的select屬性值來(lái)實(shí)現(xiàn)的,使用XPath來(lái)遍歷那些符合節(jié)點(diǎn)位置大于0并且節(jié)點(diǎn)位置小于每頁(yè)記錄數(shù)加1的那些節(jié)點(diǎn)。其中主要的語(yǔ)句是下面的一行: 
   Style.XMLDocument.selectNodes("http://xsl:for-each/@select")(1). _ 
   value = "./客戶(hù)[position() < " & intRecordsPerPage + 1 & " and "& " position() > 0]" 
   到目前為止,我們的頁(yè)面既可以實(shí)現(xiàn)排序,也實(shí)現(xiàn)動(dòng)態(tài)改變每頁(yè)顯示記錄條數(shù)的功能了,為了實(shí)現(xiàn)可重用的要求,我們還可以進(jìn)行進(jìn)一步的改進(jìn)。XPath是進(jìn)行XML/XSLT應(yīng)用開(kāi)發(fā)的一個(gè)強(qiáng)有力的工具,XPath中可以使用通配符,使XSLT樣式單文件完全不依賴(lài)于你的數(shù)據(jù)節(jié)點(diǎn)名稱(chēng)。因此,我們?cè)诟淖僗ML數(shù)據(jù)的時(shí)候,只要不改變節(jié)點(diǎn)的層次關(guān)系,可以不必改動(dòng)XSLT就可以直接使用。比如:在本例中,你可以添加或者刪除某些字段、或添加刪除一些記錄,直接使用本例中的XSLT,不但可以在表格里正常顯示出數(shù)據(jù),而且還能正常排序和分頁(yè)。 
   下面我們就分析一下是如何實(shí)現(xiàn)的。比如下面的層次關(guān)系: 
   <客戶(hù)關(guān)系表> 
   <客戶(hù)> 
   <序號(hào)></序號(hào)> 
   <姓名></姓名> 
   <電子郵件></電子郵件> 
   </客戶(hù)> 
   </客戶(hù)關(guān)系表> 
   假如我們的XSLT中有這樣一個(gè)選擇模板的句子: 
   <xsl:apply-templates select="/客戶(hù)關(guān)系表"/> 
   為了實(shí)現(xiàn)通用性的要求,我們可以使用通配符: 
   <xsl:apply-templates select="/*"/> 
   這里我們使用了子運(yùn)算符"/",它選擇了根下的所有節(jié)點(diǎn),兩者的不同點(diǎn)在于:"/客戶(hù)關(guān)系表"選擇的是根下的客戶(hù)關(guān)系表子節(jié)點(diǎn),而"/*"選擇的是根下所有的直接子節(jié)點(diǎn),在上面的XML數(shù)據(jù)格式中,二者是完全等價(jià)的。 
   對(duì)于下面的for-each循環(huán)來(lái)說(shuō): 
   <xsl:for-each select="客戶(hù)"> 
   <xsl:sort select="序號(hào)" order="ascending"/> 
   </xsl:for-each> 
   我們可以改變成這樣的形式: 
   <xsl:for-each select="./*"> 
   <xsl:sort select="./*[1]" order="ascending"/> 
   </xsl:for-each> 
   這里"./*"表示你應(yīng)當(dāng)包含進(jìn)去當(dāng)前節(jié)點(diǎn)下所有的一級(jí)子節(jié)點(diǎn),語(yǔ)法"./*[1]"表示的是選擇當(dāng)前節(jié)點(diǎn)中的第一個(gè)子節(jié)點(diǎn)。 
   另外還有一個(gè)地方可以改進(jìn)的是<xsl:value-of select="序號(hào)"/>,我們可以把它改成<xsl:value-of select="."/>,表示在每一次循環(huán)中選擇當(dāng)前節(jié)點(diǎn)。 
   在我們的函數(shù)中,還使用了一些硬代碼,如果不做改動(dòng)的話(huà),我們的通用性還是實(shí)現(xiàn)不了,因此,我們下面就看看如何替換硬代碼中的語(yǔ)句。 
   在創(chuàng)建表頭的時(shí)候,我們使用了<td onClick="sort(‘‘序號(hào)‘‘)"> 序號(hào)</td>的語(yǔ)句,如果XML數(shù)據(jù)里沒(méi)有序號(hào)節(jié)點(diǎn)的話(huà),這里顯然會(huì)出現(xiàn)錯(cuò)誤的,為了實(shí)現(xiàn)通用性,我們自定義了一個(gè)函數(shù)getName,來(lái)取得所要顯示的節(jié)點(diǎn)的名稱(chēng): 
   <td> 
   <xsl:attribute name="onClick"> 
   Sort(‘‘<xsl:value-of select="user:getName(.)"/>‘‘) 
   </xsl:attribute> 
   <xsl:value-of select="user:getName(.)"/> 
   </td> 
   自定義函數(shù)是XSLT的一個(gè)突出的功能,要使用這個(gè)特性,我們得用msxml:script元素來(lái)定義,同時(shí),必須在樣式單定義的時(shí)候指定一個(gè)用戶(hù)定義的名字空間。下面就是我們使用自定義函數(shù)的全部?jī)?nèi)容: 
   <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform 
   xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
   xmlns:user="http://lucky.myrice.com" 
   version="1.0"> 
   <msxsl:script language="VBScript" implements-prefix="user"> 
   <![CDATA[ 
   function getName(node) 
   getName = node.item(0).nodeName 
   end function 
   }> 
   </msxsl:script> 

   在我們的XSLT文件中,使用了兩個(gè)循環(huán),我們分別進(jìn)行相應(yīng)的更改,第一處:顯示表頭的地方改為<xsl:for-each select="./*[1]/*">,它等同于<xsl:for-each select="客戶(hù)關(guān)系表/客戶(hù)[1]/*">;第二處循環(huán)是顯示每行記錄,改成<xsl:for-each select="./*">。還有其他的地方需要更改的,請(qǐng)參見(jiàn)后面的完整源代碼部分。這樣我們就完成了通用的XSLT文件,不管你的XML數(shù)據(jù)有多少字段,也不管節(jié)點(diǎn)名稱(chēng)是什么,我們都無(wú)需更改XSLT文件,就可以實(shí)現(xiàn)我們的功能了。最終的瀏覽效果將會(huì)象下圖所示:  
 
    


    
    
   以下是完整的Style.xsl文件的內(nèi)容: 
   
   <?xml version="1.0" encoding="gb2312"?> 
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://lucky.myrice.com" version="1.0"> 
   <msxsl:script language="VBScript" implements-prefix="user"> 
   <![CDATA[ 
   Function getName(node) 
   getName = node.Item(0).nodeName 
   End Function 
   }> 
   </msxsl:script> 
   
   <xsl:template match="/"> 
   <xsl:apply-templates select="/*"/> 
   </xsl:template> 
   
   <xsl:template match="/*"> 
   <table width="100%" border="0" style="font-size:9pt"> 
   <tr> 
   <td align="left"><b>第 <span id="CurrentPage"></span> 頁(yè) 總 <span id="PageCount"></span> 頁(yè)    共有 <span id="RecordCount"></span> 條記錄</b></td> 
   <td align="right"><b>每頁(yè)記錄數(shù):<input onblur="setRecordsPerPage()" id="RecordsPerPage" style="vertical-align:middle;height:15pt;width:30px"/></b></td> 
   <td align="right"> 
   <span id="Paging"> 
   <input type="button" OnClick="FirstPage()" value="第一頁(yè)"/> 
   <input type="button" OnClick="previousPage(1)" value="上一頁(yè)"/> 
   <input type="button" OnClick="nextPage(1)" value="下一頁(yè)"/> 
   <input type="button" OnClick="LastPage()" value="最末頁(yè)"/> 
   </span> 
   </td> 
   </tr> 
   </table> 
   <Table WIDTH="100%" BORDER="0" cellpadding="0" cellspacing="1" style="font-size:11pt" bgcolor="#0099ff"> 
   <tr bgcolor="#FF6600" style="cursor: hand;padding:5px"> 
   <xsl:for-each select="./*[1]/*"> 
   <td align="center"> 
   <xsl:attribute name="onclick"> 
   Sort(‘‘<xsl:value-of select="user:getName(.)"/>‘‘) 
   </xsl:attribute> 
   <font color="#EEEEEE"><b><u><xsl:value-of select="user:getName(.)"/></u></b></font> 
   </td> 
   </xsl:for-each> 
   </tr> 
   <xsl:for-each select="./*[position() < 6 and position() > 0]"> 
   <xsl:sort select="./*[1]" order="ascending"/> 
   <tr bgcolor="#FFCCFF"> 
   <xsl:for-each select="./*"> 
   <td> <xsl:value-of select="."/></td> 
   </xsl:for-each> 
   </tr> 
   </xsl:for-each> 
   </Table> 
   </xsl:template> 
   </xsl:stylesheet> 
   以下是進(jìn)行輸出的Exam.htm文件: 
   <HTML> 
   <Head> 
   <META http=equiv="Content-Type" Content="text/html;charset=gb2312"> 
   <STYLE> 
   body { font-family:宋體; font-size:9pt;} 
   th { font-family:宋體; font-size:11pt; font-weight:bold;} 
   </STYLE> 
   <Script language="vbscript"> 
   Option Explicit 
   
   Dim intRecordsPerPage ‘‘每個(gè)頁(yè)面顯示的記錄數(shù) 
   intRecordsPerPage = 6 ‘‘每個(gè)頁(yè)面顯示的記錄數(shù),默認(rèn)設(shè)定為6 
   
   ‘‘ 更新顯示頁(yè)面的函數(shù) 
   Function window_onload() 
   
   ‘‘ 顯示設(shè)定的記錄數(shù) 
   Style.XMLDocument.selectNodes("http://xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]" 
   transform() 
   setPageCount() 
   
   End Function 
   
   ‘‘ 進(jìn)行XML-XSLT轉(zhuǎn)換,并顯示當(dāng)前記錄的一些信息 
   Function transform() 
   
   DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement) 
   RecordsPerPage.Value = intRecordsPerPage 
   
   End Function 
   
   ‘‘ 重新轉(zhuǎn)換XML,并顯示一個(gè)狀態(tài)信息 
   Function redisplay(intPage) 
   
   Dim strDisplay 
   Dim intPageCount 
   Dim intRecordCount 
   
   ‘‘ 保存狀態(tài)信息 
   intPageCount = PageCount.innerHTML 
   intRecordCount = RecordCount.innerHTML 
   transform() 
   ‘‘ 顯示狀態(tài)信息 
   PageCount.innerHTML = intPageCount 
   RecordCount.innerHTML = intRecordCount 
   CurrentPage.innerHTML = intPage 
   
   End Function 
   
   ‘‘ 重新排序和顯示 
   Function Sort(strField) 
   
   Dim sortField 
   Dim sortOrderAttribute 
   ‘‘ 得到排序?qū)傩灾?nbsp;
   Set sortField = Style.XMLDocument.selectSingleNode("http://xsl:sort/@select") 
   Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("http://xsl:sort/@order") 
   
   ‘‘ 改變排序的方式 
   If sortField.Value = strField Or sortField.Value = "./*[0]" Then 
   If sortOrderAttribute.Value = "descending" Then 
   sortOrderAttribute.Value = "ascending" 
   Else 
   sortOrderAttribute.Value = "descending" 
   End If 
   Else 
   sortField.Value = strField 
   sortOrderAttribute.Value = "ascending" 
   End If 
   
   Set sortField = Nothing 
   Set sortOrderAttribute = Nothing 
   
   redisplay (CurrentPage.innerHTML) 
   
   End Function 
   
   ‘‘ 重新設(shè)置每頁(yè)的記錄數(shù) 
   Function setRecordsPerPage() 
   
   If IsNumeric(RecordsPerPage.Value) Then 
   intRecordsPerPage = CInt(RecordsPerPage.Value) 
   window_onload 
   End If 
   
   End Function 
   
   ‘‘ 顯示頁(yè)數(shù)信息 
   Function setPageCount() 
   
   Dim intTotalRecords 
   
   PageCount.innerHTML = getNumberOfPages(intTotalRecords) 
   RecordCount.innerHTML = intTotalRecords 
   CurrentPage.innerHTML = 1 
   
   End Function 
   
   ‘‘ 計(jì)算總頁(yè)數(shù)和總記錄數(shù) 
   Function getNumberOfPages(intTotalRecords) 
   
   Dim intPages 
   
   intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length 
   intPages = intTotalRecords / intRecordsPerPage 
   If InStr(intPages, ".") > 0 Then 
   intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1 
   End If 
   
   getNumberOfPages = intPages 
   
   End Function 
   
   ‘‘ “下一頁(yè)”的處理 
   Function nextPage(intPage) 
   
   Dim strDisplay 
   Dim strDateRange 
   
   If CInt(CStr(intPage) * intRecordsPerPage) < Data.selectNodes("/*/*").length Then 
   intPage = CInt(intPage) + 1 
   Style.XMLDocument.selectNodes("http://@OnClick")(1).Value = "previousPage(" & intPage & ")" 
   Style.XMLDocument.selectNodes("http://@OnClick")(2).Value = "nextPage(" & intPage & ")" 
   Style.XMLDocument.selectNodes("http://xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]" 
   redisplay (intPage) 
   End If 
   
   End Function 
   
   ‘‘ 處理“上一頁(yè)” 
   Function previousPage(intPage) 
   
   Dim strDisplay 
   Dim strDateRange 
   
   If intPage > 1 Then 
   intPage = CInt(intPage) - 1 
   Style.XMLDocument.selectNodes("http://@OnClick")(1).Value = "previousPage(" & intPage & ")" 
   Style.XMLDocument.selectNodes("http://@OnClick")(2).Value = "nextPage(" & intPage & ")" 
   Style.XMLDocument.selectNodes("http://xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]" 
   redisplay (intPage) 
   End If 
   
   End Function 
   
   ‘‘ “第一頁(yè)”的處理 
   Function FirstPage() 
   
   Style.XMLDocument.selectNodes("http://@OnClick")(1).Value = "previousPage(1)" 
   Style.XMLDocument.selectNodes("http://@OnClick")(2).Value = "nextPage(1)" 
   Style.XMLDocument.selectNodes("http://xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]" 
   transform() 
   setPageCount() 
   
   End Function 
   
   ‘‘ “最末頁(yè)”的處理 
   Function LastPage() 
   
   Dim intTotalPages 
   Dim intTotalRecords 
   
   intTotalPages = getNumberOfPages(intTotalRecords) 
   nextPage (intTotalPages - 1) 
   
   End Function 
   </Script> 
   </Head> 
   <body> 
   <p align="center" style="font-weight:bold;font-size:12pt;color:#0000FF;border-bottom:3px double red;padding-bottom:5px">客戶(hù)關(guān)系表</p> 
   <XML id=‘‘Data‘‘> 
   <客戶(hù)關(guān)系表 xmlns:dt="urn:schemas-microsoft-com:datatypes"> 
   <客戶(hù)><序號(hào) dt:dt="int">01</序號(hào)><姓名>Mi</姓名><電子郵件>water@21cn.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">02</序號(hào)><姓名>uyi</姓名><電子郵件>Lily@sina.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">03</序號(hào)><姓名>uiyu</姓名><電子郵件>John@21cn.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">04</序號(hào)><姓名>Doug</姓名><電子郵件>Karry@163.net</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">05</序號(hào)><姓名>Ellen</姓名><電子郵件>vivki@sina.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">06</序號(hào)><姓名>Frank</姓名><電子郵件>net_lover@mengxianhui.com.cn</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">07</序號(hào)><姓名>Greg</姓名><電子郵件>meng@mengxianhui.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">08</序號(hào)><姓名>Harry</姓名><電子郵件>sunny@xianhui.net</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">09</序號(hào)><姓名>Ingrid</姓名><電子郵件>cathy@hotmail.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">10</序號(hào)><姓名>Jeff</姓名><電子郵件>your@mxh.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">11</序號(hào)><姓名>Kelly</姓名><電子郵件>Iloveyou@mengxianhui.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">12</序號(hào)><姓名>Larry</姓名><電子郵件>smilling@mengxianhui.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">13</序號(hào)><姓名>Mark</姓名><電子郵件>money@21cn.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">14</序號(hào)><姓名>Nancy</姓名><電子郵件>www@yahoo.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">15</序號(hào)><姓名>Peter</姓名><電子郵件>dotnet@aol.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">16</序號(hào)><姓名>Rachel</姓名><電子郵件>billgates@microsoft.com</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">17</序號(hào)><姓名>Seth</姓名><電子郵件>flying@yous.net</電子郵件></客戶(hù)> 
   <客戶(hù)><序號(hào) dt:dt="int">18</序號(hào)><姓名>Tim</姓名><電子郵件>agooyboy@lovegirl.com</電子郵件></客戶(hù)> 
   </客戶(hù)關(guān)系表> 
   </XML> 
   <XML id=‘‘Style‘‘ src=‘‘Style.xsl‘‘></XML> 
   <div id="DisplayArea"></div> 
   <table border="0" width="100%" style="font-size:11pt;"> 
   <tr> 
   <td align="right">資料來(lái)源:【<a >孟憲會(huì)之精彩世界</a>】</td> 
   </tr> 
   </table> 
   </body> 
   </HTML> 
   
   把上面的內(nèi)容拷貝到本地計(jì)算機(jī)上,分別保存為相應(yīng)的文件,在IE5+和XML3.0+的環(huán)境下即可看到效果!

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
XSLT轉(zhuǎn)換XML小結(jié)
XML查看對(duì)應(yīng)的 XSLT 樣式表
PHP5中使用XSLT擴(kuò)展
最完美的xslt數(shù)值函數(shù)與字符串函數(shù)
通過(guò)xalan實(shí)現(xiàn)關(guān)系型數(shù)據(jù)庫(kù)到XML的數(shù)據(jù)交換
xslt輕松入門(mén)(zt)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服