Solved

Limit HTML rows displayed on page with XSLT.

Posted on 2006-07-20
2
470 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
[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 Comments
 
LVL 9

Expert Comment

by:owenli27
ID: 17153582
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
ID: 17219300
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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, …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

707 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