Is merged.xml an input to your transformation or is it the output? I'm confused. Perhaps the parser is too. Perhaps your output file is inadvertently part of the input collection? That could lead to all kinds of problems, though I would generally expect something other than an XML well-formedness error.
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference