xsl分页问题
page.xml<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="page.xsl" ?>
<list>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
</list>
page.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www. version="1.0">
<xsl:param name="size" select="6"/>
<xsl:template match="list">
<html>
<script>
<![CDATA[
function nextPage(num){
document.getElementById("content"+num).style.display="";
num--;
document.getElementById("content"+num).style.display="none";
}
function prevPage(num){
document.getElementById("content"+num).style.display="";
num++;
document.getElementById("content"+num).style.display="none";
}
function onInitialize(){
var i = 1;
document.getElementById("content"+i).style.display = "";
}
]]>
</script>
<body onload="onInitialize()">
<xsl:apply-templates select="item[position() mod $size = 1]">
<xsl:with-param name="pages" select="ceiling(count(item) div $size)"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="item">
<xsl:param name="pages"/>
<xsl:variable name="page" select="position()"/>
<div id='content{$page}' style="display:'none'" title="content{$page}">
<xsl:for-each select="self::item | following-sibling::item[position()<$size]">
<div><xsl:value-of select="."/></div>
</xsl:for-each>
<div id="navBar">
<xsl:choose>
<xsl:when test="$page = 1">
第<xsl:value-of select="$page" />页---
<a href="#{$page + 1}" onclick="nextPage({$page + 1})">下一页</a>---
共有<xsl:value-of select="$pages" />页---
</xsl:when>
<xsl:when test="$page = $pages">
第<xsl:value-of select="$page" />页---
<a href="#{$page - 1}" onclick="prevPage({$page - 1})">上一页</a>---
共有<xsl:value-of select="$pages" />页---
</xsl:when>
<xsl:otherwise>
第<xsl:value-of select="$page" />页---
<a href="#{$page - 1}" onclick="prevPage({$page - 1})">上一页</a>---
<a href="#{$page + 1}" onclick="nextPage({$page + 1})">下一页</a>---
共有<xsl:value-of select="$pages" />页---
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</xsl:template>
</xsl:stylesheet>