Thank you!

We will try that.

Best regards,
Serge

Le Nov 13, 2009 à 22:02, "Caristi, Joe" <jcari...@whisolutions.com> a écrit :

This would require a custom marshaller and unmarshaller, since the class and XML structures are significantly different. Look here:



http://jibx.sourceforge.net/tutorial/binding-custom.html



From: s b [mailto:sb7...@gmail.com]
Sent: Friday, November 13, 2009 11:32 AM
To: jibx-users@lists.sourceforge.net
Subject: [jibx-users] Factorization properties of XML



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.


STATEMENT OF CONFIDENTIALITY:



The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify WHI Solutions immediately at g...@whisolutions.com ,
and destroy all copies of this message and any attachments.
--- --- --- --------------------------------------------------------------------- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to