tags:

views:

41

answers:

2

Hi,

I need to generate xmls and these differ only in the values that the tags contain. Is it possible to create a template xml and then write only the values each time?(I do not want to go the jaxb way as these are small xmls and are not worth creating objects for them). Is this a good approach?

Any thoughts / pointers will help me decide.

Thanks much, RJ

A: 

Despite the fact that you are against jaxb (which I have yet to use), I wish to recommend a comparable way to do this with Apache's XMLBeans.

This requires you to use an xml schema - but from my experience it worth it...

Yaneeve
+2  A: 

As long as the XML file to be produced is small, simple and mostly consistent in format, I tend to buck the trend: I simply create and write a text string.

writer.out.format("<?xml version='1.0'><root><tag1>%s</tag1></root>", value1)

kinda thing.

Carl Smotricz
Java doesn't stop you from doing this with a String of practically any length. For sanity's sake, though, I would set a limit at about 20 lines of output text, or perhaps 20 tags.
Carl Smotricz