Solved

Limit HTML rows displayed on page with XSLT.

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Viewing XML as a table on a Mac 3 171
Detect file exist or not 3 178
Online tools to transform xml to excel using xsl 1 47
Xsl-fo show PDF when no results are returned 2 20
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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. 
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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