Hi,
I'm using EclipseLink Moxy for my OXM mappings.
My main domain objects are something like this:
public class BuyOrder {
private Integer id;
private String odaNumber;
private String company;
private Organization expediter1;
private Organization expediter2;
private List<BuyOrderItem> orderItems;
}
public class Organization {
private Integer id;
// XML tag -> Code
private String sapCode;
// XML tag -> Description
private String companyName;
}
And my eclipselink-oxm.xml is as follow:
<?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="it.mysigl.datamodel"
xml-mapping-metadata-complete="true">
<java-type name="BuyOrder">
<xml-root-element name="Header"/>
<java-attributes>
<xml-element java-attribute="odaNumber" name="oda_number"/>
<xml-element java-attribute="company" name="company"/>
<xml-element java-attribute="orderItems" name="Item"/>
</java-attributes>
</java-type>
<java-type name="BuyOrderItem">
<java-attributes>
<xml-element java-attribute="odaPos" name="oda_pos"/>
<xml-element java-attribute="division"/>
</java-attributes>
</java-type>
<java-type name="it.mysigl.datamodel.Organization">
<java-attributes>
<xml-element java-attribute="companyName" name="oda_pos"/>
<xml-element java-attribute="sapCode" name="expediter1_code"/>
</java-attributes>
</java-type>
</java-types>
</xml-bindings>
The XML I'd need to unmarshal is like this:
<?xml version="1.0" encoding="UTF-8"?>
<IM_ME_XML_Outbound>
<Header>
<oda_number>7211000000</oda_number>
<company>NA1 </company>
<expediter1_code>0000009375</expediter1_code>
<expediter1_description>MYCOMPANY S.P.A. </expediter1_description>
<expediter2_code>0000644415</expediter2_code>
<expediter2_description>NAMIBIA PTY </expediter2_description>
<Item>
<oda_pos>00010</oda_pos>
<division>NA11</division>
</Item>
<Item>
<oda_pos>00020</oda_pos>
<division>NA12</division>
</Item>
</Header>
</IM_ME_XML_Outbound>
Would it be possible to unmarshal:
- expediter1_code
- expediter1_description
into BuyOrder.expediter1
and
- expediter2_code
- expediter2_description
into BuyOrder.expediter2?
If yes, how? Will an adapter work for this?
Thanks.
[Updated on: Tue, 20 October 2015 17:07]
Report message to a moderator