java - Convert JAXB class (not its object) to xml template -



java - Convert JAXB class (not its object) to xml template -

is there way 1 can convert jaxb class (not object) xml template.

for example

below code taken http://www.javacodegeeks.com/2011/02/jaxb-generate-xml-xsd.html

public static void main(string[] args) throws jaxbexception { objectfactory mill = new objectfactory(); usert user = factory.createusert(); user.setusername("sanaulla"); itemt item = factory.createitemt(); item.setitemname("seagate external hdd"); item.setpurchasedon("august 24, 2010"); item.setamount(new bigdecimal("6776.5")); itemlistt itemlist = factory.createitemlistt(); itemlist.getitem().add(item); expenset expense = factory.createexpenset(); expense.setuser(user); expense.setitems(itemlist); jaxbcontext context = jaxbcontext.newinstance("generated"); jaxbelement element = factory.createexpensereport(expense); marshaller marshaller = context.createmarshaller(); marshaller.setproperty("jaxb.formatted.output",boolean.true); marshaller.marshal(element,system.out); }

in above code object of class element has been create marshall. question if don't have object of jaxb class, still able generate xml template (with no values)

java xml jaxb

Comments