I would like to have a mapping that inherits the value-style set by the
enclosing element.

 

Based on this page:

http://jibx.sourceforge.net/details/value-element.html

It says style:

"defaults to the value set by the innermost containing element with a
value-style attribute, which will always be either the "attribute" or
"element" choice."

 

Given the following XML I want to unmarshall:

<customer_add_response><customer customer_id="100749"
user_code="303"/></customer_add_response>

 

If the value-style is set on the rbi.it.think.jdomain.Customer mapping,
the values are unmarshalled into the Customer object as you would
expect.

Here is the binding.

 

<binding>

    <mapping class="rbi.it.think.jdomain.Customer" abstract="true"
value-style="attribute">

               <value field="customerId" name="customer_id"
usage="optional"/>

               <value field="customerCategory" name="customer_category"
usage="optional"/>

               <value field="userCode" name="user_code"
usage="optional"/>

    </mapping>

    <mapping class="rbi.it.think.jdomain.Response" abstract="true"/>

    <mapping name="customer_add_response"
class="rbi.it.think.jdomain.CustomerAddResponse"
extends="rbi.it.think.jdomain.Response">

        <structure map-as="rbi.it.think.jdomain.Response"/>

        <structure field="customer" name="customer" usage="optional"/>

    </mapping>

</binding>

 

But, if I put the value-style instead on any enclosing element of the
Customer (and remove it from Customer), the values do not get
unmarshalled.  

e.g.  if I put value-style="attribute" on structure as:

    <mapping name="customer_add_response"
class="rbi.it.think.jdomain.CustomerAddResponse"
extends="rbi.it.think.jdomain.Response">

        <structure map-as="rbi.it.think.jdomain.Response"/>

        <structure field="customer" name="customer" usage="optional"
value-style"attribute"/>

    </mapping>

 

Or on mapping as:

    <mapping name="customer_add_response"
class="rbi.it.think.jdomain.CustomerAddResponse"
extends="rbi.it.think.jdomain.Response" value-style="attribute">

        <structure map-as="rbi.it.think.jdomain.Response"/>

        <structure field="customer" name="customer" usage="optional"/>

    </mapping>

 

I do not get any values unmarshalled into the Customer obj. 

Note that the unmarshal does not throw an exception.  It just does not
set the values.

 

Here are the pojos:

 

public class Customer implements java.io.Serializable {

    public int customerId;

    public String customerCategory;

    public String userCode;

    public Date creationDate;

}

public class Response implements java.io.Serializable {

}

public class CustomerAddResponse extends Response implements
java.io.Serializable {

    public Customer customer;

    public CustomerIdentifier customerIdentifier;

}

 

The reason I want to specify the value-style above the Customer object,
is that I want to reuse the Customer mapping in other Request (not
shown) mappings where

The value-style needs to be "element".

 

 

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to