Solved

Limit HTML rows displayed on page with XSLT.

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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