page.xsl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:param name="size" select="50"/>
  4. <xsl:template match="/">
  5. <html>
  6. <script>
  7. <![CDATA[
  8. function nextPage(num){
  9. document.getElementById("content"+num).style.display="";
  10. num--;
  11. document.getElementById("content"+num).style.display="none";
  12. }
  13. function prevPage(num){
  14. document.getElementById("content"+num).style.display="";
  15. num++;
  16. document.getElementById("content"+num).style.display="none";
  17. }
  18. function firstPage(num){
  19. document.getElementById("content"+1).style.display="";
  20. document.getElementById("content"+num).style.display="none";
  21. }
  22. function lastPage(num,last){
  23. document.getElementById("content"+last).style.display="";
  24. document.getElementById("content"+num).style.display="none";
  25. }
  26. function onInitialize(){
  27. for(var i = 0; i< 1000; i++)
  28. {
  29. var a = document.getElementById("content"+i)
  30. if(a)
  31. {
  32. document.getElementById("content"+i).style.display = "none";
  33. }
  34. var b = document.getElementById("content"+1)
  35. if(b)
  36. {
  37. document.getElementById("content"+1).style.display = "";
  38. }
  39. }
  40. }
  41. ]]>
  42. </script>
  43. <body onload="onInitialize()">
  44. <xsl:apply-templates select="data/subdata[position() mod $size = 1]">
  45. <xsl:with-param name="pages" select="ceiling(count(data/subdata) div $size)"/>
  46. </xsl:apply-templates>
  47. </body>
  48. </html>
  49. </xsl:template>
  50. <xsl:template match="data/subdata">
  51. <xsl:param name="pages"/>
  52. <xsl:variable name="page" select="position()"/>
  53. <div id='content{$page}' style="display:'none'">
  54. <table width="740" border="0" align="center" cellpadding="1" cellspacing="1" bordercolordark="#ffffff" bordercolorlight="#ADAAAD" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">
  55. <tr>
  56. <td colspan="3">
  57. <xsl:value-of select="$page" />/<xsl:value-of select="$pages" /> 页
  58. <xsl:choose>
  59. <xsl:when test="$page = 1">
  60. <span style="color:#999">第一页</span> -
  61. <span style="color:#999">上一页</span> -
  62. <a href="#{$page + 1}" onclick="nextPage({$page + 1})">下一页</a> -
  63. <a href="#{$pages}" onclick="lastPage({$page},{$pages})">最后一页</a>
  64. </xsl:when>
  65. <xsl:when test="$page = $pages">
  66. <a href="#{1}" onclick="firstPage({$page})">第一页</a> -
  67. <a href="#{$page - 1}" onclick="prevPage({$page - 1})">上一页</a> -
  68. <span style="color:#999">下一页</span>
  69. <span style="color:#999">最后一页</span>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <a href="#{1}" onclick="firstPage({$page})">第一页</a> -
  73. <a href="#{$page - 1}" onclick="prevPage({$page - 1})">上一页</a> -
  74. <a href="#{$page + 1}" onclick="nextPage({$page + 1})">下一页</a> -
  75. <a href="#{$pages}" onclick="lastPage({$page},{$pages})">最后一页</a>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </td>
  79. </tr>
  80. <tr bgcolor="#FFCC99" align="center">
  81. <td height="5" colspan="3"></td>
  82. </tr>
  83. <tr bgcolor="#FFCC99" align="center">
  84. <td height="20"><strong>变量名称</strong></td>
  85. <td><strong>值</strong></td>
  86. <td><strong>发生时间</strong></td>
  87. </tr>
  88. <xsl:for-each select="self::subdata | following-sibling::subdata[position()&lt;$size]">
  89. <tr align="center">
  90. <td bgcolor="#eeeeee" height="16"><xsl:value-of select="varname"/></td>
  91. <td bgcolor="#f3f3f3"><xsl:value-of select="value"/></td>
  92. <td bgcolor="#efefef"><xsl:value-of select="happentime"/></td>
  93. </tr>
  94. </xsl:for-each>
  95. </table>
  96. </div>
  97. </xsl:template>
  98. </xsl:stylesheet>