?
Solved

postion() is not working correctly in xsl

Posted on 2004-08-19
5
Medium Priority
?
300 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 1000 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 1000 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

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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