I have XML file having structure is as follows-
<products>
<product>
<ptype>fruits</ptype>
<varieties>
<variety>
<id>a</id>
<cost>100</cost>
</variety>
<subvarieties>
<variety>
<id>b</id>
<cost>100</cost>
</variety>
<subvarieties>
<variety>
<id>c</id>
<cost>100</cost>
</variety>
</subvarieties>
</variety>
</subvarieties>
<variety>
<id>d</id>
<cost>75</cost>
</variety>
</varieties>
</product>
<product>
<type>vegetables</type>
<varieties>
<variety>
<id>e</id>
<cost>50</cost>
</variety>
</varieties>
</product>
I need to restructure the above xml into HTML tabular format based on node <variety>. It means irrespective of the position of the node <variety> in XML, I need to select the elements under that node. Sometime the node might be empty i.e no elements under the node. Desired XML is as follows -
<html>
<body>
<table border="1">
<tr>
<td>a</td>
<td>100</td>
</tr>
<tr>
<td>b</td>
<td>100</td>
</tr>
<tr>
<td>c</td>
<td>100</td>
</tr>
<tr>
<td>d</td>
<td>75</td>
</tr>
<tr>
<td>e</td>
<td>50</td>
</tr>
</table>
</body>
</html>
Attempted XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="/products">
<xsl:for-each select="//variety">
<tr>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I am getting an empty response for the above XSLT. Any help would be a great plus.