Solved

Limit HTML rows displayed on page with XSLT.

Posted on 2006-07-20
2
425 Views
Last Modified: 2012-08-13
Hi,
I have  some xml data which I currently transform with XSLT into a HTML table, this works fine only I want to display 20 results at a time with a link to the next 20/previous 20 results, when you click the link the next 20 are displayed etc.

I am currently doing the following, which will only ever print out the first 20 rows as I have hard coded the values.....

<xsl:for-each select="page/data/line">
   <xsl:if test="@num &gt; 0 and @num &lt; 20">      
      <xsl:call-template name="show_row">
         <xsl:with-param name="line">
          <xsl:value-of select="@num"/></xsl:with-param> </xsl:call-template>        
   </xsl:if>
</xsl:for-each>


So, ideally I need buttons or html links that would increment or decrement the limits for the rows dynamically.

Is this possible with XSLT?  If so could someone give me an example? Is my code above heading in completely the wrong direction??
Your help is much appreciated.
TIA.
0
Comment
Question by:engdmorr
2 Comments
 
LVL 9

Expert Comment

by:owenli27
Comment Utility
You probably cannot do that unless you use server-side script to re-generate XSL style sheet and reset '20' (as a variable). Then re-transform xml data and display to user.  Any other XSL experts want to add some comments? Welcome drop some words here.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
Comment Utility
Hi engdmorr,

this would be though with just XSLT
and processor independence

Server scripting is one option
(if browser independence is important and you don't want to exclude server traffic,
I would definitely go for server scripting)

I would tackle this as follows
- Have a HTML stub that you open in the browser
- Have a javascript that does the transform (pulls in the XSLT and the XML)
- put the result of the transform in a div throught innerHTML or something
- it now shows the table
- have two arrows under the table: next20 and previous20 (the XSLT can handle wheither you need both buttons or not)
- pushing the arrows (buttons) call the javascript transform again, but with different parameters, giving you different rows
- make sure the javascript over-writes the current table

This would require some magic to make it work in all sorts of browsers
but it is a piece of cake if you can live with a IE only or an FireFow only solution

Cheers!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now