Am Mo, den 05.07.2004 schrieb Dennis Sosnoski um 19:42:
> Looks like you're doing some very warped things with JiBX (and I mean
> that in a good way, I think)!
yes, things can get warped when you have an existing XML-Schema, DOM
Parser, Java-Code not matching the structure and shall add code for
marshalling... but that's why i came to jibx ... :)
> 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.
>
i tried this out, but the binding compiler complains about the missing
get-method of B. it seems that get-methods with the signature you
described are not recognized. or did i misunderstand something?
class B {
C getCofA(Object a) {
return ((A)a).c;
}
...
}
<mapping class="A">
...
<structure field="b" name="B">
...
<structure get-method="getCofA" name="C">
...
==> [bind] org.jibx.runtime.JiBXException: get-method getCofA not found
in class B at tag "structure" (...)
anyway, the other solution you provided should do it for me. but if you
give me a hint what's going wrong in the example above, i could add both
solutions to the wiki.
Tilman
> 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
>
-------------------------------------------------------
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