As is so often the case with XSLT this is a grouping question.
If you are using XSLT 2.0 then use <xsl:for-each-group>, and if you are using XSLT 1.0 then you need to use the slightly more complicated Muenchian Grouping method:
http://www.jenitennison.com/xslt/gro...muenchian.html
Give it a try yourself and then if you are still stuck show us what your XSLT looks like and we'll try to help.
/- Sam Judson : Wrox Technical Editor -/