日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

僅用xsl和asp實(shí)現(xiàn)分頁功能_Xml教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:Sparks.com如何用XML和XSL來生成動(dòng)態(tài)頁面
XML(可擴(kuò)展標(biāo)記語言)看起來可能像某種W3C標(biāo)準(zhǔn)——現(xiàn)在沒有什么實(shí)際影響,即使以后能派上用場(chǎng),也是很久以后的事。但實(shí)際上,它現(xiàn)在已經(jīng)得到了應(yīng)用。所以,不要等到XML已被加進(jìn)了你最喜愛的HTML編輯器中才開始使用它。它現(xiàn)在就可以解決各種內(nèi)部問題和B2B系統(tǒng)

asp文件大致結(jié)構(gòu):
<%@ Language=VBScript %>
<!-- #include file=include/lib.asp -->
<%
cc=server.MapPath("trans.xml")
set source=server.CreateObject("msxml2.domdocument")
source.async=false
source.load(cc)

xslfile=server.MapPath("index.xsl")
set style=server.CreateObject("msxml2.domdocument")
style.async=false
style.load(xslfile)

'Response.write source.transformNode(style)
Response.write gb_html(source.transformNode(style))
Response.End
%>
------------------------------------load進(jìn)來的xml數(shù)據(jù)是這樣的:
<?xml version="1.0" encoding="GB2312" ?>
<root>
<function>
<PO>里面的標(biāo)簽在后面的xsl文件里被"<xsl:for-each>"</PO>
<PO>……………………</PO>
<PO>……………………</PO>
<PO>……………………</PO>
</function>
</root>


------------------------------------
xsl文件的內(nèi)容:

<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="include/ydzhongxin.xsl"/><!-- 嵌入頭模板,尾模板 -->
<xsl:param name="yd">7</xsl:param><!-- 調(diào)用二級(jí)導(dǎo)航條所用參數(shù) -->
<xsl:param name="page"> <xsl:value-of select="count(//PO)"/></xsl:param>

<!-- 定義根模板 -->
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<link rel="stylesheet" type="text/css" href="include/style.css"/>
<title>結(jié)果列表</title>
</head>
<body leftMargin="0" topMargin="0">
<xsl:call-template name="ydtitle"/>

<div align="center">
<xsl:apply-templates select="root/function"/>
<!-- 匹配function模板 -->
</div>

<xsl:call-template name="end"/>
</body>
</html>
</xsl:template>



<!-- 定義function模板 -->
<xsl:template match="function">
<!-- ---------------翻頁鏈接開始----------- -->
<xsl:variable name="pagesize">5</xsl:variable><!-- 是分頁參數(shù) -->

<xsl:choose>
<xsl:when test="/root/session/page[text()!='']">
<!-- 進(jìn)入一級(jí)choose的一個(gè)when條件分支!�。。�!
-------------進(jìn)入此分支,證明用戶已有翻頁操作-------------- -->
<xsl:variable name="page"><xsl:value-of select="/root/session/page"/></xsl:variable>
<table border="0" cellpadding="2" cellspacing="0" width="630">
<tr>
<td align="right">
<!-- 進(jìn)入二級(jí)choose!��! -->
<xsl:choose>
<!-- ①id小于等于0的情況,顯示最后一頁。-->
<xsl:when test="pid<1">
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)"/></xsl:attribute>
[ 首 ]</a>
<a title="前一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of
select="size*2"/></xsl:attribute>[ <<< ] </a>
<a title="后一頁">[ >>> ] </a>
<a>[ 尾 ]</a>
</xsl:when>
<!-- ②id位于[0~pagesize]之間的情況,前頁正常,后頁無。 -->
<xsl:when test="pid<(size + 1) and pid>0">
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)"/></xsl:attribute>
[ 首 ]</a>
<a title="前一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of
select="pid+size"/></xsl:attribute>[ <<< ] </a>
<a title="后一頁">[ >>> ] </a>
<a>[ 尾 ]</a>
</xsl:when>
<!-- ③id位于[pagesize~count]之間的情況,前頁無,后頁正常。 -->
<xsl:when test="pid<count(//PO) and pid>(count(//PO)-size)">
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)"/></xsl:attribute>
[ 首 ]</a>
<a title="前一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)"/></xsl:attribute>[ <<< ] </a>
<a title="后一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="pid -
size"/></xsl:attribute>[ >>> ] </a>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="size"/></xsl:attribute>
[ 尾 ]</a>
</xsl:when>

<!-- ④id等于count的情況,顯示首頁。 -->
<xsl:when test="pid=count(//PO)">
<a>[ 首 ]</a>
<a title="前一頁">[ <<< ] </a>
<a title="后一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)-size"/></xsl:attribute>[ >>> ] </a>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="size"/></xsl:attribute>
[ 尾 ]</a>
</xsl:when>
<!-- ⑤id大于count的情況,顯示首頁。 -->
<xsl:when test="pid>count(//PO)">
<a>[ 首 ]</a>
<a title="前一頁">[ <<< ] </a>
<a title="后一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)-size"/></xsl:attribute>[ >>> ] </a>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="size"/></xsl:attribute>
[ 尾 ]</a>
</xsl:when>

<!-- 正常情況 -->
<xsl:otherwise>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="count
(//PO)"/></xsl:attribute>
[ 首 ]</a>
<a title="前一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="pid +
size"/></xsl:attribute>[ <<< ] </a>
<a title="后一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="pid -
size"/></xsl:attribute>[ >>> ] </a>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="size"/></xsl:attribute>
[ 尾 ]</a>
</xsl:otherwise>
</xsl:choose>
<!-- ---------------------------------------- -->
</td>
</tr>
</table><br/>
<!-- ---------遍歷符合要求的PO結(jié)點(diǎn)------------- -->
<xsl:for-each select="PO[position()<=pid and position()>(pid - size)]">
<xsl:sort select="PO_ID" order="descending" data-type="number"/>
<xsl:call-template name="PO"/>
<br/><br/><br/>
</xsl:for-each>
<!-- 退出一級(jí)choose的一個(gè)when條件分支�。。。�! -->
</xsl:when>
<!-- ------------------用戶直接進(jìn)入的狀態(tài)------------------ -->
<xsl:otherwise>
<!-- 進(jìn)入一級(jí)choose的另一個(gè)when條件分支�。。。。� -->
<table border="0" cellpadding="2" cellspacing="0" width="630">
<tr><td align="right">
<a>[ 首 ]</a>
<a title="前一頁">[ <<< ] </a>
<a title="后一頁"><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="pid -
size"/></xsl:attribute>[ >>> ] </a>
<a><xsl:attribute name="href">search_jieguo.asp?id=<xsl:value-of select="size"/></xsl:attribute>
[ 尾 ]</a>
</td></tr>
</table><br/>
<xsl:for-each select="PO[position()<=pid and position()>(pid - size)]">
<xsl:sort select="PO_ID" order="descending" data-type="number"/>
<xsl:call-template name="PO"/>
<br/><br/><br/>
</xsl:for-each>
<!-- 退出一級(jí)choose的另一個(gè)when條件分支�。。。。� -->
</xsl:otherwise>
</xsl:choose>
<!-- --------------翻頁鏈接到此結(jié)束----------- -->
<br/>
<xsl:if test="count(//PO)=0">

<div align="center"><b>
<img src="images/msg2.gif" align="absmiddle"/>
</b><font color="#CC0000" face="楷體CS" size="3"><b>
沒有符合當(dāng)前條件的訂單</b></font>
<a><xsl:attribute name="href">lkxx.asp?po_id=<xsl:value-of select="PO_ID"/></xsl:attribute></a>
</div>
><br/><br/>
<input type="button" value="重新輸入條件查詢" onclick="location.href='search.asp'"/>
</xsl:if>
</xsl:template>






<!-- ------------------------------------------>
<xsl:template name="PO">
<table border="1" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td nowrap="nowrap" width="70"> 號(hào)碼</td>
<td nowrap="nowrap" width="110"> 名稱</td>
<td nowrap="nowrap" width="110"> 日期</td>
<td nowrap="nowrap" width="110"> 人員</td>
</tr>
<tr>
<td nowrap="nowrap"> <xsl:value-of select="num"/></td>
<td nowrap="nowrap"> <xsl:value-of select="username"/></td>
<td nowrap="nowrap"> <xsl:value-of select="dt"/></td>
<td nowrap="nowrap"> <xsl:value-of select="men"/></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

 

分享:XSL中實(shí)現(xiàn)HTML的表格自動(dòng)換行
xml數(shù)據(jù)如: root movie1/movie movie2/movie movie3/movie movie4/movie movie5/movie movie6/movie movie7/movie movie8/movie movie9/movie movie10/movie movie11/movie movie12/movie /root 要達(dá)到的效果: 1 2 3 4 5 6 7 8 9 10 11 12 XSL代碼: ?xml

來源:模板無憂//所屬分類:Xml教程/更新時(shí)間:2010-05-26
相關(guān)Xml教程