-- 作者:hexun831012
-- 发布时间:6/28/2007 4:09:00 PM
-- 重发XSL分页
鉴于firefox缓存机制问题,换了一种方式实现,还是以RSS为例 <?xml version="1.0" encoding="utf-8"?> <!--Copyright(C) 2003-2007 Hexsoft.org, All Right Reserved.--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="no" omit-xml-declaration="yes" /> <!--Page Size--> <xsl:param name="page">10</xsl:param> <!--HTML Template--> <xsl:template match="/"> <html version="1.0" xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body { font-family: Tahoma; font-size: 9pt; } </style> <script type="text/javascript"> var page; function paging(index) { if(page == null) { page = document.getElementById("1"); } page.style.display = "none"; page = document.getElementById(index); page.style.display = ""; } </script> </head> <body> <xsl:apply-templates select="rss" /> </body> </html> </xsl:template> <!--RSS Template--> <xsl:template match="rss"> <xsl:apply-templates select="channel[position() mod $page = 1]" mode="page" /> <div> <xsl:apply-templates select="channel[position() mod $page = 1]" mode="index" /> </div> </xsl:template> <!--Page Template--> <xsl:template match="channel" mode="page"> <div id="{position()}"> <xsl:if test="position() != 1"> <xsl:attribute name="style">display:none</xsl:attribute> </xsl:if> <xsl:apply-templates select=". | following-sibling::channel[position() < $page]" /> </div> </xsl:template> <!--Index Template--> <xsl:template match="channel" mode="index"> <a href="javascript:paging({position()})"> <xsl:value-of select="position()" /> </a> </xsl:template> <!--Channel Template--> <xsl:template match="channel"> <a href="{link}"> <xsl:value-of select="title" /> </a> <div> <xsl:value-of select="description" /> </div> </xsl:template> </xsl:stylesheet>
|