I would write two templates:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xrefline//*[not(self::query)]">
<xsl:apply-templates/>
</xsl:template>