Below is a way to display your xml in multiple pages with Prev and Next links. You could customize it to display any number of entries on a page. It takes in 2 parameters that could be passed as querystrings to the page.
Page - should hold the value of which page is currently displayed.
PageSize - should hold the value of how many entries should be displayed in a page.
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">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="round($mycount div $PageSize)"/>
<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>
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||