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>
in order the generated classes to implement Serializable (because you may want to save them in a db) then add to xsd:


<schema ...
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    jaxb:extensionBindingPrefixes="xjc"
    jaxb:version="1.0">

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

...



<h3>References</h3>
http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.6/jaxb/vendorCustomizations.html#serializable
http://stackoverflow.com/questions/3677088/how-to-generate-classes-from-xsd-that-implements-serializable

No comments:

Post a Comment