Hi Marcelo, You should be able to do this by duplicating some information. Basically just remove the <value> definitions from the base class (Vehicle) and use them directly within the <mapping> for the subclasses (Truck and Bus). So the <mapping> for Truck would look like:
<mapping abstract="true" class="Vehicle"/> <mapping name="Truck" class="truck" extends="Vehicle" ordered="false"> <value name="Brand" field="brand" usage="optional"/> <value name="License" field="license" usage="optional"/> <value name="Other" field="other" usage="optional"/> <value name="Wheels" field="wheels" usage="optional"/> <value name="MaxLoad" field="maxLoad" usage="optional"/> </mapping> That's assuming the fields defined in Vehicle are protected access, so that they can be referenced from Truck. If you don't want the fields to be exposed this way, you can do the same thing using get/set methods in Vehicle. The duplication needed for this is a little ugly, but it avoids the messier issues of JiBX trying to merge different groups of unordered elements (which should probably be supported - but it's a mess, and I certainly don't want to deal with it before the 2.0 code generation rewrite). - Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Marcelo Klein wrote: > Hi, I have an abstract class, an a set of implementations like this: > > class System > - collection vehicles > > class Vehicle > - String brand > - String license > - String other > > class Truck extends Vehicle > - int wheels > - int maxLoad > > class Bus extends Vehicle > - int maxPassangers > - boolean hasRestroom > > Now, I have an XML which I cannot modify, just load it into my > classes. As you can see, I have to load a collection of vehicles, from > this XML document: > <System> > <Truck> > <Brand>Saab</Brand> > <Wheels>20</Wheels> > <License>FMJ 212</License> > <MaxLoad>1500</MaxLoad> > </Truck> > <Bus> > <Brand>Saab</Brand> > <Other>It's an old bus, should be replaced</Other> > <HasRestRoom>true</Wheels> > </Truck> > </System> > > So, my problem is... > I have to load a this Vehicle collection from the Bus/Truck instances. > How can I make a mapping for this? I've tryied, but I cannot achieve > unmarshaling an unordered class which fields inherited from the > abstract class, which are also optional. Is this possible? > If you need I can send you my mapping which didn't work quite OK. > All help will be appreciated. > Thank you, > Marcelo. > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users