posted 17 years ago
I'm new to XSLT and would like to transform the following XML:
_________________________________
<item>
<data>
<tr>
<td>ROW</td>
<td>MANUFACTURER</td>
</tr>
<tr>
<td>1</td>
<td>FERRARI</td>
</tr>
<tr>
<td>2</td>
<td>PORSCHE</td>
</tr>
<tr>
<td>3</td>
<td>LAMBORGHINI</td>
</tr>
<tr>
<td>4</td>
<td>BENTLEY</td>
</tr>
<tr>
<td>5</td>
<td>ASTON MARTIN</td>
</tr>
</data>
</item>
_________________________________
What I would like to display is:
ROW MANUFACTURER
1 FERRARI
2 PORSCHE
3 LAMBORGHINI
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>
<xsl:template match="data">
<table>
<xsl:apply-templates select="tr"/>
</table>
</xsl:template>
<xsl:template match="tr">
<tr>
<xsl:apply-templates select="td"/>
</tr>
</xsl:template>
<xsl:template match="td">
<td><xsl:value-of select="."/></td>
</xsl:template>
_________________________________
Can anyone help me?