This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

is Velocity best choice for outputting XML with a template XML file?

 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.roseindia.net/apachevelocity/xml.shtml

That example above shows how to use Velocity to take in a template XML file and merge your data into it to output a populated XML file. If I want to output an XML file with dynamic data by using some kind of template tags in an XML file, is Velocity the best choice out there?

Basically, if I have a template file with stuff like



in it, do you recommend Velocity for populating it?

 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the format of the files is fixed in this way, sure, why not. Just make sure that Velocity (and/or your code) handles setting the encoding correctly. As an alternative, you could check out FreeMarker, which is the other widely used templating tool.
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip! I'm actually planning to do this on Google App Engine, and it looks like it wasn't working for someone on GAE in December due to a dependency on javax.swing:

http://solveme.wordpress.com/2009/12/25/freemarker-sucks-it-has-dependency-on-javax-swing/

I'll try Velocity for now.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used a variety of templating engines for outputting XML; they work fine.

If your needs are simple it can often be just as easy to throw stuff into the classes being output, or into a wrapper/facade.

XStream is pretty easy to use, but don't know about GAE compatibility.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic