Hello,
I am currently trying to use castor for XML binding
The problem is that I want to use the factorization properties of XML
without having to create collections in mybinded classes. Here is an
example:
I 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.
I 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 a collection 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
I haven't found a basic way to do this until now. What I can do easily
is to
create a cities class with a collection of areas, having themselves a
collection of countries...
Is there a direct way to get City objects as described ?
Regards,
G. Schaeffer