My understanding of how the <xsl:copy> and <xsl:copy-of> commands is
weak and so am having trouble figuring out the exact problem.
The rest of the stylesheet also needs looking at, eg:
<xsl:for-each select="/*/*/O/Class[text()=$notPresent]">
<xsl:apply-templates select="/*/*/O/Class[text()=$notPresent]"/>
</xsl:for-each>
and:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="@*"/>
</xsl:copy>
</xsl:template>
...are both a bit off but I'm guessing you are trying things out?