Friday, 18 November 2011

Eclipse: (0) create XSD > (1) generate automatically xml sample, and (2) generate automatically classes that read/write xml

<h3>All generated classes implement Serializable</h3>

Eclipse generated classes with xjc, the Binding Compiler. You have to enable xjc extensions in xsd and configure Eclipse (steps a and b)

step a: configure xsd

In order all the generated classes to implement Serializable (because you may want to save them in a db) then (a) add to xsd:

<schema ...

          <jaxb:globalBindings generateIsSetMethod="true">
              <xjc:serializable uid="12343"/>


step b: configure Eclipse (xjc)

On Eclipse: right click the xsd > Generate > JAXB classes ... > set package and click Next > Next > Additional Arguments: -extension


No comments:

Post a Comment