I can't think of any easy way of doing what you want. Probably the best you could do would be to use a separate object for a phone number, with an indicator for the type:

public class Phone {
   public String phoneType;
   public String number;
}

Then you could have a collection of Phones for each Shopper.

The other alternative would be to write a custom marshaller/unmarshaller for the Shopper class as a whole. I'm adding constant values for beta 4, so that may offer a cleaner way of handling this.

 - Dennis

[EMAIL PROTECTED] wrote:

Hello,

I am evaluating JIBX for use on our project.

Let me first say I've inherited a rather messy object/XML heirachy.  However,
JIBX seems suited to help us despite this.

Let's say I have this Shopper class:

public class Shopper {
   public String firstName;
   public String workPhone;
   public String dayPhone;
 }

And this XML Structure:

<shopper>
<first-name>Grover</first-name>
<phone type="work">8675309</phone>
<phone type="day">5551212</phone>
</shopper>

I found it easy to map properties like "first name".  What I'm having difficulty
with is the workPhone/dayPhone mapping.  I'm not clear on how I can switch what
field is being set by the value in the XML's "type" attribute.

If someone might show me the way, I would be very much appreciative.

I have found JIXB to be great so far, and would look forward to using it within
our application.

Thank you in advance for your time.

Best Regards,

Keith Collison




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to