I suspect this error means exactly what it says: you have used xsl:key in a position where it is not allowed. You must have a high confidence in your programming ability if you think this is a problem with the XSLT processor you are using.
It's true of course that there are processors released in the early days of XSLT 1.0 that didn't implement the spec fully. They are now a rarity. Your real question now is whether you should be moving on to XSLT 2.0. If you are doing transformations on the server the answer is almost certainly yes. That means you don't need to bother with Muenchian grouping any more, you can use xsl:for-each-group.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference