If you are processing pupils.xml the following should work
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:for-each select="school">
<!-- to insert header for the school -->
<xsl:for-each select="class">
<!-- to insert header for the class -->
<xsl:for-each select="pupil">
<xsl:if test="not(document('sports.xml')//member = .)">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Where:
not(
- get only those who don't matchdocument('sports.xml')
from this file//member
who are enclosed in<member>
at any depth= .)
who match the student we are processing.