I have solved the problem after struggling and researching a bit.
It was a problem reading text with escaped entity references. You need to set
XMLInputFactory IS_COALESCING
to true
XMLInputFactory.setProperty(XMLInputFactory.IS_COALESCING, true);
Basically this tells the parser to replace internal entity references with their respective replacement text (in other words, something like decoding) and read them as normal characters.