I found a script that will allow me to implement previous/next navigation on a web site, but I am not sure if it is correct.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="3.2" encoding="ISO-8859-1"/>
<xsl:param name="Page" select="0" />
<xsl:param name="PageSize" select="1" />
<xsl:template name="results" match="/">
<xsl:variable name="mycount" select="count(root/customer)"/>
<xsl:variable name="selectedRowCount" select="floor((number($numberOfRecords)-1) div
$recordsPerPage)+1"/>
<xsl:for-each select="root/customer">
<!-- Pagination logic -->
<xsl:if test="position() >= ($Page * $PageSize) + 1">
<xsl:if test="position() <= $PageSize + ($PageSize * $Page)">
<!-- Do display here -->
</xsl:if>
</xsl:if>
</xsl:for-each>
<!-- Prev link for pagination -->
<xsl:choose>
<xsl:when test="number($Page)-1 >= 0"> 
<A>
<xsl:attribute name="href">_dirresult?page=<xsl:value-of select="number($Page)-
1"/>&pagesize=<xsl:value-of select="$PageSize"/></xsl:attribute>
<<Prev
</A>
</xsl:when>
<xsl:otherwise>
<!-- display something else -->
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$selectedRowCount > 1">
 <b class="blacktext"><xsl:value-of select="number($Page)+1"/> of <xsl:value-of select="number($selectedRowCount)"/></b> 
</xsl:if>
<!-- Next link for pagination -->
<xsl:choose>
<xsl:when test="number($Page)+1 < number($selectedRowCount)"> 
<A>
<xsl:attribute name="href">_dirresult?page=<xsl:value-of select="number($Page)
+1"/>&pagesize=<xsl:value-of select="$PageSize"/></xsl:attribute>
Next>>
</A>
</xsl:when>
<xsl:otherwise>
<!-- display something else -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Is this script correct? As far as I can tell, “Do display here” is never reached when you are on page 1 article 1.
The way to find out whether it works, is to try it out!
First thing you will need to do, is fix some errors. This variable declaration is simply wrong because it references two other variables that do not exist
$numberOfRecords should probably be mycount, and $recordsPerPage should be $PageSize
From looking at the XSLT, it expects a list of Customer elements, like so…
Having tried it myself, it does appear to work, but do bear in mind it assumes page numbering starts at 0, not 1, so if you want to display the first page, you set the $Page parameter to 0. Don’t panic though, it will display Page 1 of … in the output.
So, give it a go, and see how you get on…