Sorry bad news. This will not work. Only possible solution (I see at the moment) would be to put the whole xsl:for-each
into the xsl:when
(with or without sort).
Your code example should than look like this:
<xsl:variable name="newspaper_group" select="./newspaper[count(. | key('newspaper_key', ./@id)[1]) = 1]" />
<xsl:choose>
<xsl:when test="$sort_newspaper = 'name'">
<xsl:for-each select="$newspaper_group" >
<xsl:sort select="./@name"/>
<!-- Sorted stuff -->
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$newspaper_group" >
<!-- Unsorted stuff -->
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>