I am generating XML using Apache Velocity. What is the best (most straight-forward) way to XML-escape the output?
(I saw there is an escape tool, but could not figure out it’s dev state. I also think that XML escaping is something that is very likely supported by Velocity directly.)
Take a look at event handlers.
Escape tool is a production ready as well if you need to escape only selective references (final version of tools was released just recently but it was in beta stage before that for 2 years if not longer)
How to init velocity tools.
Include velocity-tools.xml into your project and enable required tools:
Then velocity context creation procedure would look like: