Given a xml file with large records. I need change the xml file into html format. It's easy to display it in one page but difficult for me to paginate it. Is there any stuff about it?
I presume you are using XSLT to convert your XML to HTML. The thing that you need to do is pass a $start parameter to the XSLT to determine the records you need to display. Once you do that, thing are easy; you simply add an additional predicate to your XPath:
[(position() >= $start) and (position() < $start + 25)]
The above assumes you want to show 25 records at a time. Unfortunately, how to pass the $start parameter is a bit tricky.
1) If you are relying on the browser's XSLT transformer, you are in trouble; so far as I know, there is no generic way to pass variables to a browser's transformer.
2) If you are using server-side transformation with a JAXP Transformer, things are easier. You can use the Transformer.setParameter() method:
In your XSLT, you will need a parameter declaration in the main stylesheet, with a default value (e.g. 1).
<xsl:param name="start" select="'1'" />
Thank you for your kindness Paul.
I am using JAXP Transformer and want to display it on my jsp page.
It will do greate to me.
Thank you very much.
Here is a nice link on pagination at Java Ranch.
Steve - http://www.fdsapi.com
- An easy to use open source API to generate dynamic HTML and XML