Try this (not tested):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">
<xsl:template match="/">
<xsl:variable name="all-cds">
<xsl:for-each select="case/cd">
<xsl:copy-of select="document(concat('cd', @position, '.xml'))/cd"/>
</xsl:for-each>
</xsl:variable>
<sorted-by-artist>
<xsl:for-each select="exsl:node-set($all-cds)/cd">
<xsl:sort select="artist"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</sorted-by-artist>
</xsl:template>
</xsl:stylesheet>
Here I think it's impossible to avoid RTF to nodeset conversion. Your XSLT processor must implement EXSLT's node-set() function or something similar.
Regards,
Armen