A few points.
(a) don't use disable-output-escaping. It's completely undefined when writing to a temporary destination, as here, and it certainly does no good. And it makes you like like a programmer who will try anything rather than resort to reading the manual.
(b) don't use the construct
<xsl:variable name="x">
<xsl:value-of select="y"/>
</xsl:variable>
when you mean <xsl:variable name="x" select="y"/>.
Unless of course you get paid more for writing three lines of code where one will do, or for writing a program that takes three times longer to execute.
(c) don't use the compare() function to test for equality. compare() is an XSLT 2.0 function that returns -1 if a<b, 0 if a=b, and +1 if a>b. I think you're testing for equality, so that should give 0, not 1 as the answer, but you can test for equality using "=".
(d) don't post here saying that something causes an error without saying what the error is. You might not understand it, but the chances are that someone else does.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference