With XSLT 2.0 you can use grouping along these lines
Code:
<xsl:template match="/">
<xsl:for-each-group select="class/student" group-by="cours">
<xsl:result-document href="{current-grouping-key()}.xml">
<cours>
<xsl:copy-of select="current-group()"/>
</cours>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>
Untested but should give you an idea.