Each of these had its own limitations which reduced their feasibility within our application. Next we considered hand-coding the XML directly with API's like:
The amount of code required to create an XML document with these API's was excessive. Code like this was not fun to write nor easy to follow.
So we decided to take a different approach and use a templating engine, specifically FreeMarker. Using FreeMarker to generate the XML response messages turned out to be a great decision. This is a list of some of the advantages we have noticed:
- The FreeMarker template we wrote to create the XML response message is an XML document. This simple fact should not be overlooked.
- Easy to integrate into any application. Very little code was required to utilize FreeMarker in our application.
- Excellent performance.
- The built-in functionality that FreeMarker provides is very powerful.