This is a standard grouping problem. In XSLT 2.0, use the xsl:for-each-group instruction. In 1.0, use a technique such as Muenchian grouping described at
http://www.jenitennison.com/xslt/grouping
Generally, it's a bad idea to say three times that your question is urgent. Many people don't reply to such posts, because it often means that the question has been posted without taking the time to research available information first, and it also often means that people come back instantly with supplementary questions rather than taking the time to study and digest the answer.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference