Instead of:
s = s.replaceAll("${", "\\$\\{"); // s is \$\{/xml:Name}
s = s.replaceAll("}", "\\}"); // s is \$\{/xml:Name\}
You can use it without regex method String#replace(string)
:
s = s.replace("${", "\\$\\{").replace("}", "\\}"); // s is \$\{/xml:Name\}