<mapping name="A" class="A">
<value style="attribute" field="a_name"/>
<structure name="B">
<structure field="b">
<value style="attribute" field="b_name"/>
</structure>
<structure name="C" field="c">
<value style="attribute" field="c_name"/>
</structure>
</structure>
</mapping>Sometimes I forget how flexible the binding definition can be. On the other hand, some of these unusual uses of <structure> have been where most of the problems have occurred. Let me know if you run into any problems.
- Dennis
Dennis Sosnoski wrote:
Looks like you're doing some very warped things with JiBX (and I mean that in a good way, I think)! You should be able to do this by using a get-method added to the B class. If the get-method has the signature name(Object obj) it will be passed the containing object. You can cast this to an A and get the C reference from there.
That's obviously not as convenient as having JiBX just do it for you directly, and it's possible the binding definition could be extended to represent this. It's a pretty uncommon requirement, though.
If you find this comment useful and try it out I'd appreciate it if you could also add it to the Wiki. For what it's worth I think I've made it a little easier to use, with some basic instructions on the form to add or edit a snip.
- Dennis
Tilman Linden wrote:
hello again,
i wonder if there is a possibility to access the element stack inside of a binding definition, just like you can do inside a Custom Marshaller using getStackObject(...).
assume the following scenario:
class A { String a_name; B b; C c; }
class B { String b_name; }
class C { String c_name; }
shall be marshalled to the following XML:
<A name="a_name"> <B name="b_name"> <C name="c_name"/> </B> </A>
the following mapping should describe the problem:
<mapping name="A" class="A"> <value style="attribute" field="a_name"/> <structure name="B" field="b"> <value style="attribute" field="b_name"/> <structure name="C" field= ?HOW TO ACCESS A.c AT THIS POINT? > <value style="attribute" field="c_name"/> </structure> </structure> </mapping>
maybe it is just bad design trying to map a flat object structure to a
nested XML structure, but i encountered this problem quite a few times. if i overlooked a simple solution for this, maybe someone can point me
at it. i would like to avoid custom marshallers because then the mapping
semantics are split across the binding and the marshaller.
regards,
Tilman
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users
-- Dennis M. Sosnoski Enterprise Java, XML, and Web Services Training and Consulting http://www.sosnoski.com Redmond, WA 425.885.7197
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users
