users@jaxb.java.net

Re: JAXB customization to generate flat (less hierarchal) Java class

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 23 Apr 2009 09:59:56 +0200

Consider using the plugin for injecting additional getter and setter code
into class Car.

The insertion is done with an external customization/binding file, so you
don't have to change the schema.

You'll need to call xjc from one of the stand-alone releases. If I rember
correctly, there's an issue in the current release, where the file
META-INF/services/com.sun.tools.xjc.Plugin in jaxb-xjc.jar is
missing this line:
   com.sun.tools.xjc.addon.code_injector.PluginImpl
Please check and add, if missing.

-W


On Thu, Apr 23, 2009 at 9:33 AM, dhai <sdhari_at_hotmail.com> wrote:

>
> <xs:element name="car">
> <xs:element name="engine">
> <xs:element name="engineNumber" type="xs:string"/>
> <xs:element name="enginePower" type="xs:float"/>
> </xs:element>
> <xs:element name="body">
> <xs:element name="colour" type="xs:string"/>
> <xs:element name="length" type="xs:float"/>
> </xs:element>
> </xs:element>
>
> JAXB compiler creates following three classes for the above schema.
>
> class Car{
> protected Engine engine;
> protected body body;
> }
> class Engine{
> protected String engineNumber;
> protected float eninerPower;
> }
> class Body{
> protected String colour;
> protected float length;
> }
>
> I need a flat bean to access all the attribute from a single class. I need
> JAXB to generate the following class. I don’t have option to change xsd and
> upcoming xml request. Of course I don’t just want class generation but also
> want marshalling/unmarshalling work successfully.
>
> class car{
> protected String engineNumber;
> protected float eninerPower;
> protected String colour;
> protected float length;
> }
> --
> View this message in context:
> http://www.nabble.com/JAXB-customization-to-generate-flat-%28less-hierarchal%29-Java-class-tp23191755p23191755.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>