RE: [xsl] Pageing

Subject: RE: [xsl] Pageing
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 7 Jul 2004 15:45:41 -0400
> From: Evan Wellens [mailto:evanw@xxxxxxxxxxxxxxxxxxxx]
>          Does anyone know any tricks to pull off paging without
> server interaction. Our XML & XSL must be portable and transform
> server interaction. I know I can filter by record count with something
> like
> <xsl:if test="position() &lt; 17">

I presume that you want to display a series of records from a database

> But this type of static processing will not allow for things such as
> and previous page links ( at least I don't believe so) . 

Why not?  There are various ways you can go, depending on just what kind
of data you plan to send and whether you can dynamically do xslt
transformations in the browser (which you can with IE and also, I think,
with Mozilla).

A) The simplest thing to do is to fake the paging - put all the data on
a single page, but space each successive block of records so far down
that it isn't visible when the previous block is on the screen.  Your
stylesheet would insert hyperlinks for previous and next "pages".  I
have done this with presentations.  To a user, it looks like you are
bringing in a new page, but really you are just navigating to a
different part of the same one.  This approach does not require dynamic
xslt transformations, just one on page load, and it could be done at the

B) If you can do dynamic transformations, you can feed the stylesheet a
parameter that says which records to include on a page, and again the
stylesheet would create the hyperlinks.  This time, the hyperlinks would
probably point to javascript code to run the corresponding

C) Somewhat more painful but very still feasible is to have the
stylesheet create javascript data structures that contain all the data.
When the user pages, you would rewrite the display block (preferably a
"div" element") using a javascript function.  This approach is also very
feasible.  Again, the transformation could even be done on the server
before sending the page to the browser.

I have done A) and C) myself with good success.


Tom P

Current Thread