For-each Example

Figure 13. foreach.xml

<?xml version='1.0'?>
<table>
  <row><entry>a1</entry><entry>a2</entry></row>
  <row><entry>b1</entry><entry>b2</entry></row>
  <row><entry>c1</entry><entry>c2</entry></row>
</table>


Figure 14. foreach.xsl

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:template match="table">
  <table>
    <xsl:for-each select="row">
      <tr>
        <xsl:for-each select="entry">
          <td><xsl:apply-templates/></td>
        </xsl:for-each>
      </tr>
    </xsl:for-each>
  </table>
</xsl:template>
</xsl:stylesheet>


Figure 15. foreach.html

<table>
<tr>
<td>a1</td><td>a2</td>
</tr>
<tr>
<td>b1</td><td>b2</td>
</tr>
<tr>
<td>c1</td><td>c2</td>
</tr>
</table>


Challenge: rewrite this stylesheet in recursive terms