Guest_imported
New member
- Jan 1, 1970
- 0
how do you paginate the XML cos i have tried this xsl but it "start" parameter value does not reflect the changes. How do we modify it such that when we click the next button, it will go to the second page
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
utput method="html" />
<xsl
aram name="start">1</xsl
aram>
<xsl
aram name="perpage">10</xsl
aram>
<xsl:variable name="totalitems" select="count(//student)"/>
<xsl:variable name="end">
<xsl:choose>
<xsl:when test="($start + $perpage) > $totalitems">
<xsl:value-of select="$totalitems"/>
</xsl:when>
<xsl
therwise>
<xsl:value-of select="$start + $perpage - 1"/>
</xsl
therwise>
</xsl:choose>
</xsl:variable>
<!-- begin root template -->
<xsl:template match="/">
<h3>Showing records <xsl:value-of select="$start"/>- <xsl:value-of
select="$end"/> of
<xsl:value-of select="$totalitems"/></h3>
<table border="0" cellpadding="0" cellspacing="0">
<tr><th>Product ID</th><th>Description</th><th>Price</th></tr>
<xsl:for-each select="school/student[position() >= $start and
position() <= $end]">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
<!-- if there are records before the block we are viewing, provide a
'prev.' link -->
<xsl:if test="$start > 1">
<a href="school.xml?start={$start - $perpage};perpage={$perpage}">prev.</a>
</xsl:if>
<!-- process *all* the <item> elements in the document to build the
'google-style' navbar -->
<xsl:apply-templates select="student"/>
<!-- if there are more records, provide a 'next' link -->
<xsl:if test="$totalitems > $end">
<a href="school.xml?start2={$end + 1};perpage={$perpage}" name="siao">next</a>
</xsl:if>
</xsl:template>
<!-- end root template -->
<!-- the 'item' template that builds the numbered navbar links -->
<xsl:template match="student">
<xsl:if test="position() mod $perpage = 1 or $perpage = 1">
<xsl:variable name="pagenum">
<xsl:value-of select="ceiling(position() div $perpage)"/>
</xsl:variable>
<a href="school.xml?start={position()};perpage={$perpage}">
<xsl:value-of select="$pagenum"/>
<!-- force whitespace in between the numbered links -->
<xsl:text> </xsl:text>
</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
<xsl
<xsl
<xsl:variable name="totalitems" select="count(//student)"/>
<xsl:variable name="end">
<xsl:choose>
<xsl:when test="($start + $perpage) > $totalitems">
<xsl:value-of select="$totalitems"/>
</xsl:when>
<xsl
<xsl:value-of select="$start + $perpage - 1"/>
</xsl
</xsl:choose>
</xsl:variable>
<!-- begin root template -->
<xsl:template match="/">
<h3>Showing records <xsl:value-of select="$start"/>- <xsl:value-of
select="$end"/> of
<xsl:value-of select="$totalitems"/></h3>
<table border="0" cellpadding="0" cellspacing="0">
<tr><th>Product ID</th><th>Description</th><th>Price</th></tr>
<xsl:for-each select="school/student[position() >= $start and
position() <= $end]">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
<!-- if there are records before the block we are viewing, provide a
'prev.' link -->
<xsl:if test="$start > 1">
<a href="school.xml?start={$start - $perpage};perpage={$perpage}">prev.</a>
</xsl:if>
<!-- process *all* the <item> elements in the document to build the
'google-style' navbar -->
<xsl:apply-templates select="student"/>
<!-- if there are more records, provide a 'next' link -->
<xsl:if test="$totalitems > $end">
<a href="school.xml?start2={$end + 1};perpage={$perpage}" name="siao">next</a>
</xsl:if>
</xsl:template>
<!-- end root template -->
<!-- the 'item' template that builds the numbered navbar links -->
<xsl:template match="student">
<xsl:if test="position() mod $perpage = 1 or $perpage = 1">
<xsl:variable name="pagenum">
<xsl:value-of select="ceiling(position() div $perpage)"/>
</xsl:variable>
<a href="school.xml?start={position()};perpage={$perpage}">
<xsl:value-of select="$pagenum"/>
<!-- force whitespace in between the numbered links -->
<xsl:text> </xsl:text>
</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>