I found the problem in changeEntityRef. I propose to exchange: val = Utils.replaceAll(val, "&", "&"); with: val = val.replaceAll( "&(?!(#\\d+;|amp;))", "&"); This worked for my use cases at least fine.
Actually, hexadecimal is also allowed to for the &# expressions. So: val = val.replaceAll( "&(?!(#\\d+;|#x[0-9a-fA-F]+;|amp;))", "&"); is better.
Log in to post a comment.
Actually, hexadecimal is also allowed to for the &# expressions.
So:
val = val.replaceAll( "&(?!(#\\d+;|#x[0-9a-fA-F]+;|amp;))", "&");
is better.