It is posible to do this, as long as you have a containing superstructure - if what you want is for jibx to instantiate an A and a B for you and pass back references to both, it should be obvious why this won't work (Jibx, like any XML processor, unmarshalls and passes back a reference to a single object that contains references to other objects).  As long as you're OK with this, you can do something like:
 
public class Container
{
  private A contained_a;
  private B container_b;
}
 
<binding direction="input">
<mapping name="container" class="Container">
  <structure class="A" field="contained_a">
     <value name="input_a" field="a" />
  </structure>
  <structure class="B" field="container_b">
     <value name="input_b" field="b" />
  </structure>
</mapping>
</binding>
 
This should achieve the effect you're looking for.
 
The trick here is the use of the "structure" element to "move down" through the class hierarchy.  The "structure" element of the binding is a bit hard to get a handle on at first, but it's really the key to making the most of jibx.  The way I think of it is that the structure element lets me "walk down" the hierarchy either of classes *or* of XML children.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, October 24, 2006 8:05 AM
To: JiBX users
Subject: [jibx-users] binding -strucuture mish-mash possible ???


Hi,

Need some help on binding.
Is it possible to create a structure that draws its member elements from multiple java source files

I mean
<structure>
 <value name="a" field="a"/>
 <value name="b" field="b"/>
</structure>

class A {
        private String a;
}


class B {
        private String b;
}

Is it possible to club fields from two/three different class files like this under a single structure.

I have limited exposure to jibx and am not able to figure out how from referring the jibx tutorial on the site.

Any help with illustrations if possible will be a great help.

Thank you.

Regards,
Chetan




This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and
any attachments are believed to be free of any virus or other
defect that might affect any computer system into which it is
received and opened, it is the responsibility of the recipient to
ensure that it is virus free and no responsibility is accepted by
JPMorgan Chase & Co., its subsidiaries and affiliates, as
applicable, for any loss or damage arising in any way from its use.
If you received this transmission in error, please immediately
contact the sender and destroy the material in its entirety,
whether in electronic or hard copy format. Thank you.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to