</head> <body> <xsl:apply-templates select="ns:title"/> <xsl:apply-templates select="ns:author"/> <TABLE> <TR> <xsl:apply-templates select="ns:chapter"/> </TR> <xsl:call-template name="rowCounter"> <xsl:with-param name="N" select="1"/> </xsl:call-template> </TABLE> </body> </html> </xsl:template> <xsl:template name="rowCounter"> <xsl:param name="N"/> <xsl:if test="ns:chapter/ns:section[ $N ]"> <TR> <xsl:for-each select="ns:chapter"> <TD> <xsl:apply-templates select="ns:section[ $N ]"/> <xsl:text> </xsl:text> </TD> </xsl:for-each> </TR> <xsl:call-template name="rowCounter"> <xsl:with-param name="N" select="$N + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="ns:title"> <h1> <xsl:value-of select="."/> </h1> </xsl:template> <xsl:template match="ns:author"> <h2> <xsl:value-of select="."/> </h2> </xsl:template> <xsl:template match="ns:chapter"> <TH> <xsl:value-of select="@name"/> </TH> </xsl:template> </xsl:stylesheet>