Solved

postion() is not working correctly in xsl

Posted on 2004-08-19
5
298 Views
Last Modified: 2012-05-05
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:param name="recordsPerPage" select="10" />
<xsl:param name="pageNumber" select="page/request/parameters/pageNumber" />
<xsl:template match="page">
<HTML>
<HEAD>
<TITLE> XSLT In Java </TITLE>
<link rel="stylesheet" href="html/eSupplyTableSortCSS.css"/>

</HEAD>
<BODY class='formdata'>
<form method="post">
records:<xsl:value-of select="$recordCount" />      
pageNumber:<xsl:value-of select="$pageNumber" />
      <table cellSpacing='0' cellpadding='0'  border="1" width='95%'>
      <center>
            <tr CLASS='formheader'>
            <td><u>C</u>onsol No</td>
            <td><u>M</u>AWB No</td>
            <td><u>O</u>rigin</td>
            <td><u>D</u>estination</td>
            <td><u>A</u>irline</td>
            <td><u>F</u>light</td>
            <td><u>E</u>TD</td>
            <td>E<u>T</u>A</td>
            <td>C<u>u</u>t Off Date</td>
            </tr>
            <xsl:for-each select="ROWSET/ROW">
            <!--this performs the output in table format - and shows
only that many records passed in the recordcount parameter -->

<xsl:if test="position() &gt;  $recordsPerPage * number($pageNumber) and position() &lt;= number($recordsPerPage * number($pageNumber) +
            $recordsPerPage)">
            <!-- Each record on a seperate row -->
            position:::<xsl:value-of select="position()" />
            <tr  class='formdata'>
            <td>
                  <xsl:value-of select="CONSOLEID" />
            </td>

            <td>
                  <xsl:value-of select="MASTERDOCID" />
            </td>

            <td>
                  <xsl:value-of select="ORIGIN" />
            </td>

            <td>
                  <xsl:value-of select="DESTINATION" />
            </td>

            <td>
                  <xsl:value-of select="CARRIERID" />
            </td>

            <td>
                  <xsl:value-of select="FLIGHT_NO" />
            </td>
            <td>
                  <xsl:value-of select="ETD" />
            </td>
            <td>
                  <xsl:value-of select="ETA" />
            </td>
            <td>
                  <xsl:value-of select="CUTOFF_DATE" />
            </td>
            </tr>
      </xsl:if>
      </xsl:for-each>
</table>
<table cellSpacing='0' cellpadding='0'  border="1" width='95%'>
<tr class='formdata'>
<td width="10%">
            <xsl:if test="$pageNumber > 0">
                  <xsl:element name="a">
<xsl:attribute name="href">?pagenumber=<xsl:value-of select="number($pageNumber)-1" />&amp;previous=Previous</xsl:attribute>
                         Previous
                  </xsl:element>                    
            </xsl:if>
</td>
<td width="85%">
            <!-- Next page, do not show when at end() of listing -->
            <xsl:if test="($recordCount - ((1+number($pageNumber)) *
$recordsPerPage))> 0">
                  <xsl:element name="a">
            <xsl:attribute name="href">emp.jsp?pagenumber=<xsl:value-of select="number($pageNumber)+1" />&amp;next=Next</xsl:attribute>
                               Next
                  </xsl:element>
            </xsl:if>
            <!-- End Of Show previous/next page links-->
      </td>
      </tr>
      </table>
      </form>
            </BODY>
            </HTML>
      </xsl:template>
</xsl:stylesheet>

above is xsl paging code  

look at this condition
in this condition initially pageNumber=0;

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

            first time it is displaying 10 records and i am displaying positions <xsl:value-of select="position()" />
            it is coming correctly 1-10

            when i click next button it is coming 11-20

            above condition working perfectly

when i changed the condition like this
in this condition initially pageNumber=1;
<xsl:if test="position() &lt;= number($recordsPerPage) * number($pageNumber)">

first time it is displaying 1-10 records

when i click next button it is coming  1-20 records but it should come 11-20 why ithe position has come to 1st again;

where went wrong

0
Comment
Question by:chaitu chaitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 250 total points
ID: 11840328
shouldn't it be
<xsl:if test="position() &lt;= number($recordsPerPage) * number($pageNumber) and position() &gt; number($recordsPerPage) * number($pageNumber - 1)">
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 250 total points
ID: 11840482
Try changing your test to:

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

Expert Comment

by:Carl Tawn
ID: 11840485
doh, beat me to it ;o)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question