XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 6th, 2002, 07:45 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Display in number of rows.

Hi, i need to know how to display for example 10 records in each page. for eg, i have 30 records, i want it to be in 3 pages and there will be a "next" button where i can go to the next page.
the codes i currently have is this:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xslutput method="html" />

<xslaram name="start">1</xslaram>
<xslaram name="perpage">10</xslaram>
<xsl:variable name="totalitems" select="count(//student)"/>
<xsl:variable name="end">
<xsl:choose>
<xsl:when test="($start + $perpage) > $totalitems">
<xsl:value-of select="$totalitems"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="$start + $perpage - 1"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>

<!-- begin root template -->

<xsl:template match="/">

<h3>Showing records <xsl:value-of select="$start"/> - <xsl:value-of
select="$end"/> of
<xsl:value-of select="$totalitems"/></h3>

<table border="0" cellpadding="0" cellspacing="0">
<tr><th>Product ID</th><th>Description</th><th>Price</th></tr>
<xsl:for-each select="school/student[position() >= $start and
position() <= $end]">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>

<!-- if there are records before the block we are viewing, provide a
'prev.' link -->
<xsl:if test="$start > 1">
<a href="school.xml?start={$start - $perpage};perpage={$perpage}">prev.</a>
</xsl:if>

<!-- process *all* the <item> elements in the document to build the
'google-style' navbar -->
<xsl:apply-templates select="student"/>

<!-- if there are more records, provide a 'next' link -->
<xsl:if test="$totalitems > $end">
<a href="school.xml?start={$end + 1};perpage={$perpage}" name="">next</a>
</xsl:if>


</xsl:template>

<!-- end root template -->

<!-- the 'item' template that builds the numbered navbar links -->
<xsl:template match="student">
<xsl:if test="position() mod $perpage = 1 or $perpage = 1">
<xsl:variable name="pagenum">
<xsl:value-of select="ceiling(position() div $perpage)"/>
</xsl:variable>
<a href="school.xml?start={position()};perpage={$perpage}">
<xsl:value-of select="$pagenum"/>
<!-- force whitespace in between the numbered links -->
<xsl:text> </xsl:text>
</a>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Display in number of rows.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway