473,889 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pagination using XSL

10 New Member
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code.

Below is the code that i have written for pagination but it displays the link of all the pages at one go i.e. if i have 8 pages showing 10 results per page than it shows links for all 8 pages.

Previous 1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80 Next

i want to restrict that number to 5 and whenever the user clicks the 31-50 link then it should delete the entry for 1-10 and new entry for 51-60 should come up.

I am unable to implement this functionality. can anyone help me regarding this? Please guide if i am i am doing right or not?
Please provide me with links to tutorials on pagination concepts, it would be a great help to me..

The code is :

<!-- Calculate first records -->
<xsl:variable name="firstitem " select="/Properties/Data/External/paginate/nextIndex"/>
<xsl:variable name="lastitem" select="$firsti tem + 10"/>

<!-- Calculate total number of records -->
<xsl:variable name="total" select="count(/Properties/Data/Datum[@Name='Summary']/DCR/cntSummary/cntSummaryConte nt)"/>

<xsl:template match="/">
<table id="p-columns" cellspacing="10 ">
<tr>
<td id="p-center">
<div class="p-article-summary-without">
<script type="text/javascript">
function callScript(a)
{ document.pagina tion.nextIndex. value = a * 10; document.pagina tion.submit();
}
</script>
<form name="paginatio n">
<input name="nextIndex " type="hidden" value="0"/>
</form>

<!-- Display the 'Results(xx to yy) of zz' -->
<h3> <strong>Results </strong> (
<strong>
<xsl:value-of select="$firsti tem + 1"/>-
<xsl:choose><xs l:when test="$firstite m + 9 &lt; $total">
<xsl:value-of select="$firsti tem + 10"/>
</xsl:when><xsl:o therwise> <xsl:value-of select="$total"/></xsl:otherwise>
</xsl:choose>
</strong>) of <xsl:value-of select="$total"/>
</h3>

<table cellspacing="0" >
<xsl:variable name="path" select="/Properties/Data/Datum[@Name='Sorting']/Option[@Selected='true ']/Value"/>
<xsl:choose>
<xsl:when test="$path='da te'">
<xsl:for-each select="Propert ies/Data/Datum[@Name='Summary']/DCR/cntSummary/cntSummaryConte nt">
<xsl:sort order="descendi ng" select="cntSumm aryHeading/itmDate"/>
<xsl:if test="position( ) &gt; $firstitem and position() &lt;= $lastitem ">
<tr>
<!-- If first instance, then put the class="p-top" -->
<xsl:if test="position( ) = $firstitem + 1"><xsl:attribu te name="class">p-top</xsl:attribute>
</xsl:if>
</tr>
<tr>
<td class="p-text">
<h5>
<a target="main">
<xsl:choose>
<xsl:when test="cntSummar yHeading/itmLinkType='ex ternal'">
<xsl:attribut e name="href">
<xsl:value-of select = "cntSummaryHead ing/itmHyperlink"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="cntSummar yHeading/itmLinkType='in ternal'">
<xsl:attribut e name="href"> <xsl:value-of select = "cntSummaryHead ing/dependent_itmPa gelink"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:attribut e name="title">
<xsl:value-of select="cntSumm aryHeading/itmText"/></xsl:attribute>
<xsl:attribut e name="target">
<xsl:value-of select="cntSumm aryHeading/itmTarget"/>
</xsl:attribute>
<xsl:value-of select="cntSumm aryHeading/itmText"/>
</a>
</h5>
</td>
</tr></table>
</xsl:if>
</div>

<xsl:if test="$total &gt; 10">
<div id="srcPaginato r">
<table class="p-paginator" cellspacing="0" >
<tr>
<!-- Find how many tabs are required -->

<xsl:variable name="tabs" select="floor(( $total - 1) div 10) + 1"/>
<td class="p-text">More results:</td>

<!-- Previous if required -->
<xsl:if test="floor($fi rstitem div 10)!= '0'">
<td class="p-previous">
<a>
<xsl:attribut e name="href">jav ascript:callScr ipt(<xsl:value-of select="floor($ firstitem div 10) - 1"/>);</xsl:attribute>
&lt; previous
</a>¦
</td>
</xsl:if>

<!-- Create the paginator tabs -->
<xsl:call-template name="paginator .loop">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="count"><x sl:value-of select="$tabs * 10"/></xsl:with-param>
</xsl:call-template>

<!-- More if required -->
<xsl:if test="floor($la stitem div 10)!= $tabs">
<td class="p-next">
¦<a>
<xsl:attribut e name="href">jav ascript:callScr ipt(<xsl:value-of select="floor($ lastitem div 10)"/>);</xsl:attribute>
next >
</a>
</td>
</xsl:if>

</tr></table>
</div>
</xsl:if>
</td>
</tr>
</table>
</xsl:template>

<!-- Begin: Define The paginator loop for creating paginator -->
<xsl:template name="paginator .loop">

<xsl:param name="i"/>
<xsl:param name="count"/>

<!-- Create the form -->
<xsl:if test="$i &lt; $count">
<td>
<!-- Find which tab is corresponding to current page -->
<xsl:choose>
<xsl:when test="$i = $firstitem + 1">
<!-- This tab corresponds to current page -->
<!-- No hyperlink -->
<!-- class="p-active" -->
<xsl:attribut e name="class">p-active</xsl:attribute>

<xsl:value-of select="$i"/>
-
<xsl:choose>
<xsl:when test="$i+9 &lt; $total">
<xsl:value-of select="$i+9"/>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="$total"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwis e>
<!-- This tab does not corresponds to current page -->
<!-- Its a hyperlink -->
<!-- class="p-link" -->
<xsl:attribut e name="class">p-link</xsl:attribute>
<a>
<xsl:attribut e name="href">jav ascript:callScr ipt(<xsl:value-of select="floor($ i div 10)"/>);</xsl:attribute>

<xsl:value-of select="$i"/>
-
<xsl:choose>
<xsl:when test="$i+9 &lt; $total">
<xsl:value-of select="$i+9"/>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="$total"/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:if>

<!-- Repeat the loop until finished -->
<xsl:if test="$i &lt; $count">
<xsl:call-template name="paginator .loop">
<xsl:with-param name="i">
<xsl:value-of select="$i + 10"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
Jul 16 '07 #1
1 6855
jkmyoung
2,057 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="Properties/Data/Datum[@Name='Summary']/DCR/cntSummary/cntSummaryContent"> 
-->

Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="Properties/Data/Datum[@Name='Summary']/DCR/cntSummary/cntSummaryContent[position() &gt;= $firstitem and position() &lt;= $lastitem"> 
Jul 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2337
by: Chris H | last post by:
I am having a problem with pagination, basically the problem is happening in the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue the increment and decrement operators aren't functioning or the $page variable isnt working in that part of the code... Below is the link to the working but broken page.. as well as the main part of my code... Hopefully someone can explain why the operators arent working or maybe see what i...
4
3656
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed and reaches a specific length, it terminates printing that page, prints a page number, and then begins to print the next page using the same header and format as the previous page. The page uses no tables or paragraph elements, only CSS. IOW, I...
1
1849
by: OceanBreeze | last post by:
I am new to .Net. I am using ASP 2.0 and C#. I want to pupolate a data grid programatically using the values obtained from a list conating domain objects. E.g., DAL.GetEmployee() returns a List of all Employee object. Each Employee object has two attributes (ID and Name). I drop a data grid control on ASP.Net Web form. Data grid will have 2 columns - one to display ID, another to display Name of employee.
0
1639
by: OceanBreeze | last post by:
I am using C# Page_Laod function to populate a web page with a table populated with several records. The table, rows (containing values) are popuated programatically with the values obtained from a list. I want to have pagination in that table control. My question: 1) Can it it done without writing any customn SQL code?
3
6410
Unicron
by: Unicron | last post by:
Hi folks, I have been working on a property listing search for a company for a while now and have hit a roadblock. I have searched the net up and down. A lot of Google results lead to this site, but I have never been able to get it to work. Here's the setup- The user submits search criteria via POST. The results php page pulls the $_POST array and displays the results with pagination of 20 results per page with links for Next/Previous. ...
16
2789
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
1
3566
markrawlingson
by: markrawlingson | last post by:
Hello, For starters: Yes, I am new to asp.net, however I hold a good 9-10 years of experience working with classic asp and am only just now upgrading my skills. I'm picking asp.net up pretty quickly but I'm running into a stumbling block that I just can't seem to get around. I think I know what the problem is, and I'm pretty confident in a work around, but it's not quite what I had hoped for so I thought I'd pick some of the experts brains...
4
3585
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it, and the pagination almost works. The first page of the pagination works fine, but when I click on one of the links for one of the next pages, the page is blank. I have seen people mention this problem, and they have been told that a variable is...
2
2598
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters kindly help <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title>
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10442
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7997
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7150
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.