I have two for-each statements iterating and I want the output to be in vertical rather than horizontal format within the table.Currently it outputs:\[code\]a b c1 2 3\[/code\]I want it to output:\[code\]a 1b 2c 3\[/code\]Can someone help please? Here is the XSL:\[code\] <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xslutput method="html" indent="no"/> <xsl:key name="names" match="Niche" use="."/> <xsl:key name="niche" match="row" use="Niche"/> <xsl:template match="/"> <table border="1"> <xsl:for-each select="//Niche[generate-id() = generate-id(key('names',.)[1])]"> <xsl:sort select="."/> <td> <xsl:value-of select="."/> </td> </xsl:for-each> <td><tr></tr></td> <xsl:for-each select="//row[generate-id(.)=generate-id(key('niche', Niche)[1])]"> <xsl:sort select="Niche"/> <td> <xsl:value-of select="count(key('niche', Niche))"/> </td> </xsl:for-each> </table> </xsl:template></xsl:stylesheet>\[/code\]Sample XML:\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/14415133/sample.xsl" ?><root> <row> <Niche>a</Niche> </row> <row> <Niche>b</Niche> </row> <row> <Niche>b</Niche> </row> <row> <Niche>c</Niche> </row> <row> <Niche>c</Niche> </row> <row> <Niche>c</Niche> </row></root>\[/code\]