Hi Ian,

You can do part of what you want by splitting the binding for A into an 
abstract mapping (which basically has the content definition you've 
already got in place) and a separate concrete mapping with the element 
name "a" (which just invokes the abstract mapping). That way your 
AWrapper mapping can directly invoke the abstract mapping for the A value.

The problem is that you'd then have two concrete mappings for the name 
"a", which doesn't work (assuming you're doing both input and output - 
it'd work for an output-only binding) - JiBX needs to know which type of 
object to create when it sees the "a" element. Can you instead use 
different names for the two variations?

Other than that, if you're using these classes (and the associated XML 
format) in different contexts you could define a <structure> for each in 
context, rather than a <mapping>.

Finally, if it's worth the effort to you you should be able to write 
custom marshaller/unmarshaller code which could handle this. The custom 
code would handle the added attributes of the AWrapper directly, then 
invoke an abstract mapping for the A class.

Hope some of that gives you an idea how to proceed.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Dees, Ian (GE Healthcare) wrote:
> Hi list,
>  
> I'm trying to marshall a "wrapper" object that adds two attributes to
> one of our previously-bound classes.
>
> For example, we have a class "A":
>
> class A {
>   private Foo foo;
>   private Bar bar;
> }
>
> that looks something like this when marshalled:
>
> <a>
>   <foo V="123">
>     <fooBar/>
>   </foo>
>   <bar V="456"/>
> </a>
>
> My wrapper class "AWrapper":
>
> class AWrapper {
>   private A wrappedA;
>   private String status;
> }
>
> adds status information, and I'd like it to look like this:
>
> <a status="status string">
>   <foo V="123">
>     <fooBar/>
>   </foo>
>   <bar V="456"/>
> </a>
>
> I have successfully written the binding for class "A", but because
> "AWrapper" doesn't extend A, I don't think JiBX will let me do what I
> want, right?
>
> Thanks,
> Ian
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to