We have had this problem: sanitizing rich text yields invalid XML: you get < br > tag without < /br > tags. Do a replaceAll of < br > with < br/ >:
replaceAll($Entity/Attribute, '<br>', '<br/>')
I was facing this Issue, you might be storing ckeditor value in unlimited String . Pass the unlimited string to a custom Java Action with following Piece of code
Document doc = Jsoup.parse(UnlimitedString, "UTF-8");
doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
outHtml = doc.toString();
And then Pass outHtml to Doc Generator Activity . It will work .