Incorrect number in list and missing nodes

Hi guys,

Working on a list where the first item/node in the list is missing (by design).  This bit is working fine but there are only 4 items on each page and the last item/node is missing... Any ideas why?

Here is the code:

 

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

<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#x00A0;">]>

<xsl:stylesheet  version="1.0"

  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  xmlns:msxml="urn:schemas-microsoft-com:xslt"

  xmlns:umbraco.library="urn:umbraco.library"

  exclude-result-prefixes="msxml umbraco.library">

  <xsl:output method="xml" omit-xml-declaration="yes"/>

 

  <xsl:param name="currentPage"/>

<xsl:variable name="recordsPerPage" select="5"/>

    <xsl:variable name="pageNumber">

      <xsl:choose>

        <xsl:when test="umbraco.library:RequestQueryString('page') &lt;= 1 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">1</xsl:when>

        <xsl:otherwise>

          <xsl:value-of select="umbraco.library:RequestQueryString('page')"/>

        </xsl:otherwise>

      </xsl:choose>

    </xsl:variable>

    <xsl:variable name="numberOfRecords" select="count($currentPage/parent::*/ReviewerSection/ReviewerBioPage/Review [@isDoc and string(./umbracoNaviHide) != '1'])"/>

 

 

  <xsl:template match="featuredImage">

<img src="{.}"  />

</xsl:template>

 <xsl:template match="headshot">

<img src="{.}" alt="{./headshot}" title="{./firstName}" />

</xsl:template>

   <xsl:template match="/">

  <xsl:variable name="excerptLength">

    <xsl:choose>

      <xsl:when test="string(/macro/excerptLength) != ''">

        <xsl:value-of select="/macro/excerptLength"/>

      </xsl:when>

      <xsl:otherwise>150</xsl:otherwise>

    </xsl:choose>

  </xsl:variable>

 

 <xsl:variable name="numberOfItems">

    <xsl:choose>

      <xsl:when test="/macro/numberOfItems != ''">

        <xsl:value-of select="/macro/numberOfItems"/>

      </xsl:when>

      <xsl:otherwise>9999</xsl:otherwise>

    </xsl:choose>

  </xsl:variable>

    <xsl:variable name="recordsPerPage" select="5"/>

 

<ul>

      <xsl:for-each select="$currentPage/parent::*/ReviewerSection/ReviewerBioPage/Review [@isDoc and string(./umbracoNaviHide) != '1']">

<xsl:sort select="datePosted" order="descending" />

        <xsl:if test="position() &gt; $recordsPerPage * number($pageNumber - 1) and position() &lt;= number($recordsPerPage * number($pageNumber - 1) + $recordsPerPage )">

 

 

 

<li>

<figure>

<a href="{umbraco.library:NiceUrl(@id)}"><xsl:apply-templates select="ancestor-or-self::*[normalize-space(featuredImage)][1]/featuredImage" /></a>

<!--<span class="wordrated">show STOPPER</span>-->

</figure>

<div class="revlist">

<h3><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" disable-output-escaping="yes"/> - <span class="sml"><xsl:value-of select="typeOfProduction"/></span></a></h3>

<figure>

 

<xsl:apply-templates select="ancestor-or-self::*[normalize-space(headshot)][1]/headshot" /></figure>

<h5><xsl:value-of select= "umbraco.library:FormatDateTime(datePosted, 'dd/MM/yyyy')" /> | reviewed by <b><xsl:value-of select="../firstName"/>&nbsp;<xsl:value-of select="../surname"/></b></h5>

<p>

  <xsl:choose>

                <xsl:when test="string($excerptLength) != '0'">

                  <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(mainReviewContent), number($excerptLength), '...')" disable-output-escaping="yes"/>

                </xsl:when>

                <xsl:otherwise>

                  <xsl:value-of select="mainReviewContent" disable-output-escaping="yes"/>

                </xsl:otherwise>

              </xsl:choose>

  </p> <a href="{umbraco.library:NiceUrl(@id)}" class="read">Read the full review</a>

 

</div><!--revlist-->

</li>

 

 

 

        </xsl:if>

      </xsl:for-each>

 </ul>

<xsl:if test="$pageNumber &gt; 1">

      <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$pageNumber - 1}" class="navbuttonprev">Previous Page</a>

    </xsl:if>

    <xsl:call-template name="for.loop">

      <xsl:with-param name="i">500</xsl:with-param>

      <xsl:with-param name="page" select="$pageNumber"></xsl:with-param>

      <xsl:with-param name="count" select="ceiling(count($currentPage/*[@isDoc and string(./umbracoNaviHide) != '1']) div $recordsPerPage)"></xsl:with-param>

    </xsl:call-template>

    <xsl:if test="(($pageNumber) * $recordsPerPage) &lt; ($numberOfRecords)">

      <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$pageNumber + 1}" class="navbuttonnext">Next Page</a>

    </xsl:if>

  </xsl:template>

 

  <xsl:template name="for.loop">

    <xsl:param name="i"/>

    <xsl:param name="count"/>

    <xsl:param name="page"/>

    <xsl:if test="$i &lt;= $count">

      <xsl:if test="$page != $i">

        <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$i}" class="navbutton">

          <xsl:value-of select="$i" />

        </a>

      </xsl:if>

      <xsl:if test="$page = $i">

        <xsl:value-of select="$i" />

      </xsl:if>

    </xsl:if>

    <xsl:if test="$i &lt;= $count">

      <xsl:call-template name="for.loop">

        <xsl:with-param name="i">

          <xsl:value-of select="$i + 1"/>

        </xsl:with-param>

        <xsl:with-param name="count">

          <xsl:value-of select="$count"/>

        </xsl:with-param>

        <xsl:with-param name="page">

          <xsl:value-of select="$page"/>

        </xsl:with-param>

      </xsl:call-template>

    </xsl:if>

  </xsl:template>

</xsl:stylesheet>


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/60258-incorrect-number-in-list-and-missing-nodes