That XML formed by
String t =abc+def; //generated xml
isn't well-formed. In particular you've created a document from concatenating two existing XML documents, and consequently it doesn't have a single root node. I don't quite know what you want to achieve (perhaps transform each XML document and then concatenate), but your concatenation of the two docs is certainly not valid.