The XML Template Engine
2024-12-25 by Frank Cheung
The XML Template Engine
I need to template to do the jobs like MyBatis <if><else><foreach>
. However, it's not easy to achieve it.
MyBatis is using own XML parser with OGNL expression engine, details here.
It's hard to copy that.
Another way is to use the common template engine, like Thymeleaf/Freemarker, but it's too heavy I think.
Beetl is a sharp project, better than Java HTML template engines, and it mentions the library ANTLR like a compiler.
It's a advanced topic, I don't think I can handle it well.
However, I'm considering to put this problem on other hand, This is a question about how to implement your own DSL.
At this point, dropincc.java, a small parser generator, comes into my eyes, and the author says,
it ships with a template engine
that can be used to generatetemplate engine, which is exactly what I need. But I can't find its implementation in the project!
So, The ANTLR's StringTemplate is the best choice. StringTemplate seems to be the only choice.