I’d like to share a bunch of inner classes between two JAXB Schema defined classes. Is this possible? The goal is to be able to assign the instances of the inner classes from one Schema defined instance of an object of type X to another Schema defined instance of an object of type Y. I am noting I am using NetBeans because I am using their interface to the JAXB toolkit to do this. Sometimes that messes things up…
Here is a more specific example (not the actual one I am coding):
<ford-taurus>
<ford-specific-tag>324dfs</ford-specific-tag>
<engine>8 Cylandar</engine>
<transmission>
<type>Manual</type>
<number-of-gears>6</number-of-gears>
</transmission>
<color>blue</color>
</ford-taurus>
<bmw-5-series>
<bmw-specific-tag></bmw-specific-tag>
<engine></engine>
<transmission>
<type></type>
<number-of-gears></number-of-gears>
</transmission>
<color></color>
</bmw-5-series>
Then in Java, after having marshalled the two files, I would want to do something like this:
myBMW.setTransmission( myFord.getTransmission() );
Does that make sense? Is it possible?
Thanks-in-advance,
Guido
If you have types shared between multiple schemas, then I would recommend having one XML schema to represent the shared types and have the other schemas import it.
Then you can use the episode file extension in the XJC tool to generate classes from the imported XML schema that can be shared.