You really need to rewrite this code. You are trying to output lexical XML (angle bracket markup) by using disable-output-escaping, and that simply isn't the right way to use XSLT. XSLT is about creating trees first, and serializing them later. When you want to create an element, you should either use a literal result element in the stylesheet, or an xsl:element instruction. The instructions that create the attributes and children of an element in the result tree should be children of the instructions that create that element.
As a result your code structure is all wrong, and your problem with the error message you reported is a symptom of this. Sorry to be brutal, but I would chuck out what you have and start again, with the firm resolution never to use d-o-e.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference