This is very easy in XSLT 2.0 using "group-adjacent":
Code:
<xsl:for-each-group select="Transaction" group-adjacent="Account-ID">
--- output account details ---
<xsl:for-each select="current-group()">
--- output transaction details
It's much harder in XSLT 1.0; you will need to use "sibling recursion" rather than a for-each loop.
Both techniques should be well covered in your favourite Wrox textbook.