新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → 全世界最好的XSL分页 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 41397 个阅读者浏览上一篇主题  刷新本主题   平板显示贴子 浏览下一篇主题
     * 贴子主题: 全世界最好的XSL分页 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     hexun831012 帅哥哟,离线,有人找我吗?天秤座1983-10-12
      
      
      威望:1
      等级:研二(Pi-Calculus看得一头雾水)(版主)
      文章:800
      积分:5114
      门派:XML.ORG.CN
      注册:2006/12/8

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给hexun831012发送一个短消息 把hexun831012加入好友 查看hexun831012的个人资料 搜索hexun831012在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看hexun831012的博客楼主
    发贴心情 全世界最好的XSL分页

    全世界最好的XSL分页是用XPath,而不是隐藏
    本文以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 omit-xml-declaration="yes"/>
     <!--Declare Current Page-->
     <xsl:param name="current">1</xsl:param>
     <!--Declare Page Size-->
     <xsl:param name="page">10</xsl:param>
     <!--HTML Template-->
     <xsl:template match="/">
      <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
        <title>XSL Paging</title>
        <style type="text/css">*{font-family:Tahoma;font-size:9pt}a{padding:1px}div{text-indent:12px}</style>
        <script type="text/javascript">function paging(page){var xmlDocument=document.XMLDocument;var xslDocument=document.XSLDocument;xslDocument.selectNodes("xsl:stylesheet/xsl:template[@match='/']").removeAll();xslDocument.selectSingleNode("xsl:stylesheet/xsl:param[@name='current']").text=page;document.body.innerHTML=xmlDocument.transformNode(xslDocument);}</script>
       </head>
       <body>
        <xsl:apply-templates/>
       </body>
      </html>
     </xsl:template>
     <!--RSS Template-->
     <xsl:template match="rss">
      <xsl:apply-templates select="channel[position() &gt;= ($current - 1) * $page and position() &lt;= $current * $page]"/>
      <xsl:call-template name="page"/>
     </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>
     <!--Page Template-->
     <xsl:template name="page">
      <xsl:for-each select="channel[position() mod $page = 1]">
       <a href="javascript:paging({position()})">
        <xsl:value-of select="position()"/>
       </a>
      </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/4/17 14:39:00
     
     GoogleAdSense天秤座1983-10-12
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/28 1:00:21

    本主题贴数13,分页: [1] [2]

     *树形目录 (最近20个回帖) 顶端 
    主题:  全世界最好的XSL分页(1831字) - hexun831012,2007年4月17日
        回复:  说实话,这种xsl分页的性能的确相当好,但是我自己还是发现一个问题,由于firefox没有缓存机制..(582字) - hexun831012,2007年6月27日
        回复:  请问一下楼主,<xsl:apply-templates select="channel[pos..(122字) - dgsd22,2007年6月14日
        回复:  上文写错了,是:然后自己编一个XML文件,并绑定了上去。(53字) - wlpx,2007年5月27日
        回复:  我的做法是,在Dreamweaver8 中新建了一个XSL整页,然后用你发出来的命令复盖所有他自动..(232字) - wlpx,2007年5月27日
        回复:  顶!我能看出来是好东西,但还有点看不明白。(171字) - wlpx,2007年5月27日
        回复:  ding(4字) - lovesky20008,2007年5月25日
        回复:  重法全世界最好的分页,支持firefox啦!!!<?xml version="1.0" enco..(3004字) - hexun831012,2007年4月25日
        回复:  本文只适用于RSS,要是其他格式xml,当然要改改了(44字) - hexun831012,2007年4月21日
        回复:  有消息回复我(60字) - lit0302,2007年4月20日
        回复:  hehe(168字) - lit0302,2007年4月20日
        回复:  有点看头,改天慢慢烟酒!(23字) - Qr,2007年4月17日
        回复:  申请精华(8字) - hexun831012,2007年4月17日

    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    56.885ms