Simple paging in results

08/12/2012 03:05

<?xml version="1.0" encoding="iso-8859-1"?>

<!-- Edited by Lukas Sevcik® -->

<xsl:stylesheet version="1.0"


    <xsl:param name="pageNr" select="2"/>

    <xsl:param name="pageSize" select="2"/>

    <xsl:variable name="startPosition" select="$pageNr*$pageSize - $pageSize+1"/>

    <xsl:variable name="endPosition" select="$pageSize*$pageNr"/>


    <xsl:template match="/">









    <xsl:template match="Row">


        Title: <xsl:value-of select="@Title"/>

        Position: <xsl:value-of select="position()"/>


            <xsl:when test="(not(position() &gt; $endPosition)) and (position() &gt;= $startPosition)">

                Item is on the page: <xsl:value-of select="$pageNr"/>



                Item is out of page






    <xsl:template match="Rows">


        Page Nr: <xsl:value-of select="$pageNr"/>

        Page size: <xsl:value-of select="$pageSize"/>

        Start position: <xsl:value-of select="$startPosition"/>

        End position: <xsl:value-of select="$endPosition"/>








Input Xml:

<?xml version="1.0" encoding="utf-8"?>



        <Row Title="E_Blog1"/>

        <Row Title="A_Blog2"/>

        <Row Title="D_Blog3"/>

        <Row Title="B_Blog4"/>

        <Row Title="C_Blog5"/>

        <Row Title="F_Blog6"/>






Page Nr: 2 Page size: 2 Start position: 3 End position: 4

Title: E_Blog1 Position: 1 Item is out of page

Title: A_Blog2 Position: 2 Item is out of page

Title: D_Blog3 Position: 3 Item is on the page: 2

Title: B_Blog4 Position: 4 Item is on the page: 2

Title: C_Blog5 Position: 5 Item is out of page

Title: F_Blog6 Position: 6 Item is out of page