This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Displaying first n rows of XML data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Displaying first n rows of XML data" Watch "Displaying first n rows of XML data" New topic

Displaying first n rows of XML data

Ravi Mann

Joined: Jun 29, 2001
Posts: 8
I'm new to XSLT and would like to transform the following XML:


What I would like to display is:


So, a parameter would be passed to the XSLT (in this case 3) and the first <tr> element would be displayed (the heading) and all other <tr> elements whose first <td> element value <= 3.

My current XSL displays all the data:

<xsl:template match="/item">
<xsl:apply-templates select="data"/>

<xsl:template match="data">
<xsl:apply-templates select="tr"/>

<xsl:template match="tr">
<xsl:apply-templates select="td"/>

<xsl:template match="td">
<td><xsl:value-of select="."/></td>

Can anyone help me?
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Perhaps this will get you started:
[ August 07, 2007: Message edited by: Paul Clapham ]
I agree. Here's the link:
subject: Displaying first n rows of XML data
Similar Threads
How to dynamically create or modify XSL
xml and hyperlinks
Using XSL to display XML
Why aren't DENSITY & DISTANCE text displayed?
different colors to different rows