Do try to learn how to use template rules and xsl:apply-templates. You can code XSLT without using these constructs, but it's a bit like riding a bicycle without using the gears.
There's presumably a Document element in your input that you haven't shown us? If there are multiple ItemList elements and you are trying to group within each one, then that's quite difficult using the Muenchian method, because Muenchian grouping relies on keys which work at document level.
I suspect that the thing that's stopping your code working is
<xsl:for-each select="//Item[generate-id(.) = generate-id(key('rows',Code)[1])]" >
the fact that Code is an attribute not an element, so it should be @Code.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference