opensubscriber
   Find in this group all groups
 
Unknown more information…

j : jibx-users@lists.sourceforge.net 14 November 2009 • 12:31AM -0500

[jibx-users] Factorization properties of XML
by s b

REPLY TO AUTHOR
 
REPLY TO GROUP






Hello,

We are currently trying to use JiBX

The problem is that we want to use the factorization properties of XML
without having to create ArrayLists in our binded classes. Here is an
example:

We have the following XML:
<cities>
   <area zone="1">
      <country code="FR">
         <city>
            <code>NCE</code>
            <zipcode>06000</zipcode>
         </city>
         <city>
            <code>PAR</code>
            <zipcode>75000</zipcode>
         </city>
      </country>
      <country code="DE">
         <city>
            <code>BER</code>
            <zipcode>123456</zipcode>
         </city>
      </country>
   </area>
   <area zone="2">
      <country code="US">
         <city>
            <code>NYC</code>
            <zipcode>111111</zipcode>
         </city>
         <city>
            <code>LAX</code>
            <zipcode>222222</zipcode>
         </city>
      </country>
   </area>
</cities>

Areas, countries and cities can all be repeated.
We would like to map this XML into the following class:

public class City {
   public int Zone;
   public String Country;
   public int Zipcode;
   public String Code;
}

The example would then produce a cities class having an arraylist of City
objects as follows:
City object 1 : Zone=1, Country=FR, Zipcode=06000, Code=NCE
City object 2 : Zone=1, Country=FR, Zipcode=75000, Code=PAR
City object 3 : Zone=1, Country=DE, Zipcode=123456, Code=BER
City object 4 : Zone=2, Country=US, Zipcode=111111, Code=NYC
City object 5 : Zone=2, Country=US, Zipcode=222222, Code=LAX

We haven't found a basic way to do this. What we can do easily is to create
a cities class with an ArrayList of areas, having themselves an arraylist of
countries...
Is there a direct way to get City objects as described ?


Thanks in advance and best regards,
Serge

PS: this message has already been posted 2 days ago but didn't appear on the
list. Sorry if this message is a duplicate.

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.