如何使用 Apache Velocity 进行 XML 转义?
我正在使用 Apache Velocity 生成 XML。 XML 转义输出的最佳(最直接)方法是什么?
(我看到有一个转义工具,但无法弄清楚它的开发状态。我还认为 XML 转义很可能是由 Velocity 直接支持的。)
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.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看事件处理程序。
如果您只需要转义选择性引用,转义工具也可以用于生产(工具的最终版本最近刚刚发布,但在此之前它处于测试阶段至少有 2 年)
如何初始化速度工具。< /strong>
将velocity-tools.xml包含到您的项目中并启用所需的工具:
然后velocity上下文创建过程将如下所示:
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: