Solved

Limit HTML rows displayed on page with XSLT.

Posted on 2006-07-20
2
438 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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, …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

15 Experts available now in Live!

Get 1:1 Help Now